ZamaKlinikV2 / app.py
AeternumS's picture
init
32965bb
raw
history blame
1.56 kB
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.")