Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
chore: update
Browse files
dev.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import shutil
|
2 |
|
3 |
from pathlib import Path
|
@@ -7,7 +9,8 @@ import pandas as pd
|
|
7 |
from concrete.ml.sklearn import LogisticRegression as ConcreteLogisticRegression
|
8 |
from concrete.ml.deployment import FHEModelDev
|
9 |
|
10 |
-
|
|
|
11 |
TRAINING_FILE_NAME = "./data/Training_preprocessed.csv"
|
12 |
TESTING_FILE_NAME = "./data/Testing_preprocessed.csv"
|
13 |
|
@@ -15,8 +18,6 @@ TESTING_FILE_NAME = "./data/Testing_preprocessed.csv"
|
|
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 |
|
@@ -26,14 +27,17 @@ y_test = df_test[TARGET_COLUMN[0]].values.flatten()
|
|
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)
|
|
|
1 |
+
"""Generating deployment files."""
|
2 |
+
|
3 |
import shutil
|
4 |
|
5 |
from pathlib import Path
|
|
|
9 |
from concrete.ml.sklearn import LogisticRegression as ConcreteLogisticRegression
|
10 |
from concrete.ml.deployment import FHEModelDev
|
11 |
|
12 |
+
|
13 |
+
# Data files location
|
14 |
TRAINING_FILE_NAME = "./data/Training_preprocessed.csv"
|
15 |
TESTING_FILE_NAME = "./data/Testing_preprocessed.csv"
|
16 |
|
|
|
18 |
df_train = pd.read_csv(TRAINING_FILE_NAME)
|
19 |
df_test = pd.read_csv(TESTING_FILE_NAME)
|
20 |
|
|
|
|
|
21 |
# Split the data into X_train, y_train, X_test_, y_test sets
|
22 |
TARGET_COLUMN = ["prognosis_encoded", "prognosis"]
|
23 |
|
|
|
27 |
X_train = df_train.drop(TARGET_COLUMN, axis=1)
|
28 |
X_test = df_test.drop(TARGET_COLUMN, axis=1)
|
29 |
|
30 |
+
# Concrete ML model
|
31 |
+
|
32 |
# Models parameters
|
33 |
optimal_param = {"C": 0.9, "n_bits": 13, "solver": "sag", "multi_class": "auto"}
|
34 |
|
|
|
35 |
clf = ConcreteLogisticRegression(**optimal_param)
|
36 |
|
37 |
+
# Fit the model
|
38 |
clf.fit(X_train, y_train)
|
39 |
|
40 |
+
# Compile the model
|
41 |
fhe_circuit = clf.compile(X_train)
|
42 |
|
43 |
fhe_circuit.client.keygen(force=False)
|