Spaces:
Build error
Build error
Commit
·
097c2b7
1
Parent(s):
32965bb
fix
Browse files
app.py
CHANGED
|
@@ -8,28 +8,6 @@ from sklearn.tree import DecisionTreeClassifier #using sklearn
|
|
| 8 |
# Load the saved model
|
| 9 |
dt = joblib.load('heart_disease_dt_model.pkl')
|
| 10 |
|
| 11 |
-
# Load the dataset and select the relevant features
|
| 12 |
-
data = pd.read_csv('data/heart.xls')
|
| 13 |
-
|
| 14 |
-
# Perform the correlation analysis
|
| 15 |
-
data_corr = data.corr()
|
| 16 |
-
|
| 17 |
-
# Select features based on correlation with 'output'
|
| 18 |
-
feature_value = np.array(data_corr['output'])
|
| 19 |
-
for i in range(len(feature_value)):
|
| 20 |
-
if feature_value[i] < 0:
|
| 21 |
-
feature_value[i] = -feature_value[i]
|
| 22 |
-
|
| 23 |
-
features_corr = pd.DataFrame(feature_value, index=data_corr['output'].index, columns=['correlation'])
|
| 24 |
-
feature_sorted = features_corr.sort_values(by=['correlation'], ascending=False)
|
| 25 |
-
feature_selected = feature_sorted.index
|
| 26 |
-
|
| 27 |
-
# Clean the data by selecting the most correlated features
|
| 28 |
-
clean_data = data[feature_selected]
|
| 29 |
-
|
| 30 |
-
# Extract the first row of feature data for prediction (excluding 'output' column)
|
| 31 |
-
sample_data = clean_data.iloc[0, 1:].values.reshape(1, -1) # Reshape to 2D array for model input
|
| 32 |
-
|
| 33 |
#fhe_circuit =
|
| 34 |
# Make prediction on the first row of data
|
| 35 |
#prediction = dt.predict(sample_data, fhe="execute")
|
|
|
|
| 8 |
# Load the saved model
|
| 9 |
dt = joblib.load('heart_disease_dt_model.pkl')
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
#fhe_circuit =
|
| 12 |
# Make prediction on the first row of data
|
| 13 |
#prediction = dt.predict(sample_data, fhe="execute")
|
client.py
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
from concrete.ml.deployment import FHEModelDev, FHEModelClient, FHEModelServer
|
| 2 |
-
|
| 3 |
-
# Setup the client
|
| 4 |
-
client = FHEModelClient(path_dir=fhe_directory, key_dir="/tmp/keys_client")
|
| 5 |
-
serialized_evaluation_keys = client.get_serialized_evaluation_keys()
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
# Load the dataset and select the relevant features
|
| 9 |
-
data = pd.read_csv('data/heart.xls')
|
| 10 |
-
|
| 11 |
-
# Perform the correlation analysis
|
| 12 |
-
data_corr = data.corr()
|
| 13 |
-
|
| 14 |
-
# Select features based on correlation with 'output'
|
| 15 |
-
feature_value = np.array(data_corr['output'])
|
| 16 |
-
for i in range(len(feature_value)):
|
| 17 |
-
if feature_value[i] < 0:
|
| 18 |
-
feature_value[i] = -feature_value[i]
|
| 19 |
-
|
| 20 |
-
features_corr = pd.DataFrame(feature_value, index=data_corr['output'].index, columns=['correlation'])
|
| 21 |
-
feature_sorted = features_corr.sort_values(by=['correlation'], ascending=False)
|
| 22 |
-
feature_selected = feature_sorted.index
|
| 23 |
-
|
| 24 |
-
# Clean the data by selecting the most correlated features
|
| 25 |
-
clean_data = data[feature_selected]
|
| 26 |
-
|
| 27 |
-
# Extract the first row of feature data for prediction (excluding 'output' column)
|
| 28 |
-
sample_data = clean_data.iloc[0, 1:].values.reshape(1, -1) # Reshape to 2D array for model input
|
| 29 |
-
|
| 30 |
-
encrypted_data = client.quantize_encrypt_serialize(sample_data)
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|