-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreating Prediction Function
More file actions
27 lines (20 loc) · 913 Bytes
/
Copy pathCreating Prediction Function
File metadata and controls
27 lines (20 loc) · 913 Bytes
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
symptoms = X.columns.values
symptom_index = {symptom: idx for idx, symptom in enumerate(symptoms)}
def predict_disease(input_symptoms):
input_symptoms = input_symptoms.split(",")
input_data = [0] * len(symptom_index)
for symptom in input_symptoms:
if symptom in symptom_index:
input_data[symptom_index[symptom]] = 1
input_data = np.array(input_data).reshape(1, -1)
rf_pred = encoder.classes_[rf_model.predict(input_data)[0]]
nb_pred = encoder.classes_[nb_model.predict(input_data)[0]]
svm_pred = encoder.classes_[svm_model.predict(input_data)[0]]
final_pred = mode([rf_pred, nb_pred, svm_pred])
return {
"Random Forest Prediction": rf_pred,
"Naive Bayes Prediction": nb_pred,
"SVM Prediction": svm_pred,
"Final Prediction": final_pred
}
print(predict_disease("Itching,Skin Rash,Nodal Skin Eruptions"))