ZamaKlinikV2 / client.py
AeternumS's picture
init
32965bb
raw
history blame
1.17 kB
from concrete.ml.deployment import FHEModelDev, FHEModelClient, FHEModelServer
# Setup the client
client = FHEModelClient(path_dir=fhe_directory, key_dir="/tmp/keys_client")
serialized_evaluation_keys = client.get_serialized_evaluation_keys()
# 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
encrypted_data = client.quantize_encrypt_serialize(sample_data)