mirror of
https://github.com/luxfhe/examples.git
synced 2026-10-30 18:13:15 +00:00
ML examples: - credit_scoring: Credit risk prediction with HMEQ data - disease_prediction: Healthcare ML on encrypted records - cifar: Encrypted image classification - federated_learning: Distributed FHE training - hybrid_model: Mixed FHE/plaintext inference Deployment: - breast_cancer: Cancer detection API - sentiment_analysis: Encrypted NLP - server: FHE inference server Blockchain: - hardhat-template: Solidity + FHE - react-template: Full dApp with FHE
24 lines
707 B
Python
24 lines
707 B
Python
import numpy
|
|
from sklearn.datasets import load_breast_cancer
|
|
|
|
from concrete.ml.deployment import FHEModelClient, FHEModelDev, FHEModelServer
|
|
from concrete.ml.sklearn import XGBClassifier
|
|
|
|
if __name__ == "__main__":
|
|
# First get some data and train a model.
|
|
X, y = load_breast_cancer(return_X_y=True)
|
|
|
|
assert isinstance(X, numpy.ndarray)
|
|
assert isinstance(y, numpy.ndarray)
|
|
|
|
# Split X into X_model_owner and X_client
|
|
X_train = X[:-10]
|
|
y_train = y[:-10]
|
|
|
|
# Train the model and compile it
|
|
model = XGBClassifier(n_bits=2, n_estimators=8, max_depth=3)
|
|
model.fit(X_train, y_train)
|
|
model.compile(X_train)
|
|
dev = FHEModelDev("./dev", model)
|
|
dev.save(via_mlir=True)
|