File size: 1,559 Bytes
32965bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import numpy as np
import pandas as pd
import joblib   # for loading the saved model
from sklearn.tree import DecisionTreeClassifier                  #using sklearn decisiontreeclassifier

#from concrete.ml.sklearn.xgb import DecisionTreeClassifier

# Load the saved model
dt = joblib.load('heart_disease_dt_model.pkl')

# Load the dataset and select the relevant features
data = pd.read_csv('data/heart.xls')

# Perform the correlation analysis
data_corr = data.corr()

# Select features based on correlation with 'output'
feature_value = np.array(data_corr['output'])
for i in range(len(feature_value)):
    if feature_value[i] < 0:
        feature_value[i] = -feature_value[i]

features_corr = pd.DataFrame(feature_value, index=data_corr['output'].index, columns=['correlation'])
feature_sorted = features_corr.sort_values(by=['correlation'], ascending=False)
feature_selected = feature_sorted.index

# Clean the data by selecting the most correlated features
clean_data = data[feature_selected]

# Extract the first row of feature data for prediction (excluding 'output' column)
sample_data = clean_data.iloc[0, 1:].values.reshape(1, -1)  # Reshape to 2D array for model input

#fhe_circuit = 
# Make prediction on the first row of data
#prediction = dt.predict(sample_data, fhe="execute")
prediction = dt.predict(sample_data) # clair

# Display the prediction result
print(prediction)
if prediction == 1:
    print("Prediction: The patient is likely to have heart disease.")
else:
    print("Prediction: The patient is unlikely to have heart disease.")