mirror of
https://github.com/luxfi/torus-ml.git
synced 2026-10-30 15:15:23 +00:00
The distribution called itself torus-ml while shipping a package directory named concrete, so the name a user installs and the name they import disagreed — and most of the tree already said torus.ml, which could not resolve against src/concrete. Moved src/concrete to src/torus and pointed the include at it. The dependency was Zama's concrete-python from their index. It is torus-fhe from ours, which is what luxfhe/torus already ships: that frontend declares torus-fhe and ships a torus/fhe module, so every 'from torus.fhe' in this tree was already naming our compiler and only the dependency lagged. Two distributions share one namespace, which is the shape the upstream this forked from used and the reason the split works: torus-fhe gives torus.fhe, torus-ml gives torus.ml. Swept every other spelling — identifiers, enum members, workflow variables, filenames, notebooks. LICENSE and NOTICE keep the upstream attribution a fork owes; the figures carry the old name in JPEG metadata a text sweep cannot reach.
2.8 MiB
2.8 MiB
In [1]:
# Source:
# https://scikit-learn.org/stable/auto_examples/classification/plot_classifier_comparison.html
# Code source: Gaël Varoquaux
# Andreas Müller
# Modified for documentation by Jaques Grobler
# Modified to integrate Torus ML functions by Lux
# License: BSD 3 clause
import warnings
warnings.simplefilter(action="ignore", category=FutureWarning)
from functools import partial
import torch
from torus.ml.sklearn import (
DecisionTreeClassifier,
LinearSVC,
LogisticRegression,
NeuralNetClassifier,
RandomForestClassifier,
XGBClassifier,
)In [2]:
# The simulation mode allows to measure the impact of FHE execution on accuracy
# without paying the cost of FHE computations.
# However, data is not encrypted when using the simulation: the model performs inference
# on clear data.
%run utils/classifier_comparison_utils.pyIn [3]:
params_neural_net = {
"module__n_w_bits": 2,
"module__n_a_bits": 4,
"module__n_accum_bits": 32,
"module__n_hidden_neurons_multiplier": 6,
"module__n_layers": 2, # 1 hidden layer
"module__activation_function": torch.nn.ReLU,
"max_epochs": 400,
"verbose": 0,
"lr": 0.001,
}
neural_network_classifiers = [
(
partial(NeuralNetClassifier, batch_size=32, **params_neural_net),
"Neural Net",
),
]
# pylint: disable-next=undefined-variable
make_classifier_comparison("NN Classifiers", neural_network_classifiers, 0.5, simulate=True) # noqaIn [4]:
linear_classifiers = [
(partial(LinearSVC, C=0.025), "Linear SVC"),
(LogisticRegression, "Logistic Regression"),
]
# pylint: disable-next=undefined-variable
make_classifier_comparison("Linear Classifiers", linear_classifiers, 0, simulate=True, h=1) # noqaIn [5]:
tree_classifiers = [
(partial(DecisionTreeClassifier, max_depth=5), "Decision Tree"),
(partial(RandomForestClassifier, max_depth=4, n_estimators=5), "Random Forest"),
(partial(XGBClassifier, n_jobs=1, max_depth=4, n_estimators=5), "XGB"),
]
# pylint: disable-next=undefined-variable
make_classifier_comparison( # noqa
"Tree-Based Classifiers", tree_classifiers, 0.5, simulate=True, h=0.1
)