kcelia commited on
Commit
ac73113
1 Parent(s): 0b860a9

chore: add a dev.py file to allow the user to generate server.py and client.py by his own

Browse files
Files changed (2) hide show
  1. dev.py +48 -0
  2. requirements.txt +1 -1
dev.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import shutil
2
+
3
+ from pathlib import Path
4
+
5
+ import pandas as pd
6
+
7
+ from concrete.ml.sklearn import LogisticRegression as ConcreteLogisticRegression
8
+ from concrete.ml.deployment import FHEModelDev
9
+
10
+ # Files location
11
+ TRAINING_FILE_NAME = "./data/Training_preprocessed.csv"
12
+ TESTING_FILE_NAME = "./data/Testing_preprocessed.csv"
13
+
14
+ # Load data
15
+ df_train = pd.read_csv(TRAINING_FILE_NAME)
16
+ df_test = pd.read_csv(TESTING_FILE_NAME)
17
+
18
+ print(df_train.shape)
19
+ print(df_train.columns)
20
+ # Split the data into X_train, y_train, X_test_, y_test sets
21
+ TARGET_COLUMN = ["prognosis_encoded", "prognosis"]
22
+
23
+ y_train = df_train[TARGET_COLUMN[0]].values.flatten()
24
+ y_test = df_test[TARGET_COLUMN[0]].values.flatten()
25
+
26
+ X_train = df_train.drop(TARGET_COLUMN, axis=1)
27
+ X_test = df_test.drop(TARGET_COLUMN, axis=1)
28
+
29
+ # Models parameters
30
+ optimal_param = {"C": 0.9, "n_bits": 13, "solver": "sag", "multi_class": "auto"}
31
+
32
+ # Concrete ML model
33
+ clf = ConcreteLogisticRegression(**optimal_param)
34
+
35
+ clf.fit(X_train, y_train)
36
+
37
+ fhe_circuit = clf.compile(X_train)
38
+
39
+ fhe_circuit.client.keygen(force=False)
40
+
41
+ path_to_model = Path("./deployment_logit/").resolve()
42
+
43
+ if path_to_model.exists():
44
+ shutil.rmtree(path_to_model)
45
+
46
+ dev = FHEModelDev(path_to_model, clf)
47
+
48
+ dev.save(via_mlir=True)
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
  concrete-ml==1.4.0
2
- gradio==3.35.2
3
  uvicorn>=0.21.0
4
  fastapi>=0.93.0
 
1
  concrete-ml==1.4.0
2
+ gradio==3.40.1
3
  uvicorn>=0.21.0
4
  fastapi>=0.93.0