mirror of
https://github.com/luxfhe/docs.git
synced 2026-10-30 18:13:39 +00:00
2.7 MiB
2.7 MiB
In [1]:
from functools import partial
# 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.
def make_classifier_comparison_from_sklearn(*args, **kwargs):
return args, kwargs
%run utils/classifier_comparison_utils.pyIn [2]:
from concrete.ml.sklearn import (
DecisionTreeClassifier,
LinearSVC,
LogisticRegression,
RandomForestClassifier,
XGBClassifier,
)In [3]:
%%time
linear_classifiers = [
(partial(LinearSVC, C=0.025), "Linear SVC"),
(LogisticRegression, "Logistic Regression"),
]
# pylint: disable-next=undefined-variable
make_classifier_comparison_from_sklearn(
"Linear Classifiers", linear_classifiers, 0, simulate=True, h=1
) # noqaCPU times: user 27 s, sys: 5.96 s, total: 32.9 s Wall time: 6.2 s
In [4]:
%%time
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_from_sklearn( # noqa
"Tree-Based Classifiers", tree_classifiers, 0.5, simulate=True, h=0.1
)CPU times: user 1d 3h 26min 25s, sys: 51min 48s, total: 1d 4h 18min 14s Wall time: 14min 6s