|
import shutil |
|
import sys |
|
from pathlib import Path |
|
|
|
from concrete.ml.deployment import FHEModelDev |
|
from concrete.ml.deployment import FHEModelClient |
|
|
|
|
|
def compile_and_make_it_deployable(model_dev, X_train): |
|
|
|
path_to_model = Path("compiled_model") |
|
|
|
|
|
model_dev.compile(X_train) |
|
|
|
|
|
shutil.rmtree(path_to_model, ignore_errors=True) |
|
fhemodel_dev = FHEModelDev(path_to_model, model_dev) |
|
fhemodel_dev.save(via_mlir=True) |
|
|
|
|
|
|
|
|
|
from sklearn.datasets import make_classification |
|
from sklearn.model_selection import train_test_split |
|
|
|
from concrete.ml.sklearn import LogisticRegression |
|
|
|
x, y = make_classification(n_samples=1000, class_sep=2, n_features=30, random_state=42) |
|
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=42) |
|
|
|
model_dev = LogisticRegression() |
|
model_dev.fit(X_train, y_train) |
|
|
|
|
|
compile_and_make_it_deployable(model_dev, X_train) |
|
print("Your model is ready to be deployable.") |
|
|