We created a script to benchmark the logistic regression library. The script does the following:
- Takes train & test data from a dataset in sklearn.
- Fills a Noir test with the training data that calls
train_multi_class
. - Runs Noir test and saves printed weights & bias.
- Calculates accuracy of those parameters according to the test data.
Note that there are conversions happening of the data in between as the original data is in floating-point representation and the Noir library works with Quantized which is a fixed point representation.
The execution of the scripts requires nargo
version 1.0.0-beta.0
and bb
version 0.63.0
. To install both CLI applications, you can execute the following commands in the terminal:
$ noirup --version 1.0.0-beta.0
$ bbup -v 0.63.0
To run a single test for the logistic regression library, you can execute the following command:
$ ./run_single_test.sh
Before running the command, you should make sure that the script is executable with $ chmod +x run_single_test.sh
.
The script has some optional parameters that you can set. The parameters are presented next:
--epochs=<n_epochs>
--samples-train=<n_samples_train>
--samples-test=<n_samples_test>
--dataset=<"iris" | "wine" | "digits" | "diabetes" | "linnerud">
The default values for each parameter are:
epochs
: 10samples-train
: 30samples-test
: 20dataset
: "iris"
To execute the dataset digits with 20 epochs, 50 training samples and 20 (default) test samples, you can execute the following commands:
$ ./cleanup.sh
$ ./run_single_test.sh --dataset=digits --epochs=20 --samples-train=50
We implemented scripts that automatically generates Noir code to compile the program, create proofs and verify these proofs using the existing Noir tooling. The command presented next generates the dataset as in the above commands, populates the Prover.toml
, and creates a Noir main
function that calls train_multi_class
. Then, it follows these steps to execute the program, prove and verify the proof.
$ ./cleanup.sh
$ ./run_proof_example.sh
We creates the same Noir program similar to the proving & verifying command presented in the previous section, but instead of executing those steps, this command just obtains the gatecount. For a single set of parameters, the output is saved in output/benchmarks.txt
. The command to execute the gate count is presented next:
$ ./cleanup.sh
$ ./run_get_gatecount.sh
To run multiple benchmarks at once gathering the output in benches/benchmarks.csv
, you can execute the following commands:
$ ./cleanup.sh
$ ./run_get_multiple_gatecounts.sh