Compilation
Compilation to FHE
Built-in models
clf.compile(X_train)scikit-learn pipelines
import numpy
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from concrete.ml.sklearn import LogisticRegression
from sklearn.decomposition import PCA
from sklearn.pipeline import Pipeline
# Create the data for classification:
X, y = make_classification(
n_features=30,
n_redundant=0,
n_informative=2,
random_state=2,
n_clusters_per_class=1,
n_samples=250,
)
# Retrieve train and test sets:
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.4, random_state=42)
model_pca = Pipeline(
[
("preprocessor", PCA()),
("cml_model", LogisticRegression(n_bits=8))
]
)
model_pca.fit(X_train, y_train)
# Compile the Concrete ML model
model_pca["cml_model"].compile(X_train)
model_pca.predict(X_test[[0]], fhe="execute")Custom models
FHE simulation
A simple Concrete example
Last updated
Was this helpful?