def diagnose_condition(symptoms, age_group=None): """Prevents the segfault from bringing the entire process down. This function *MUST* be run in a background thread. For example: symptoms = ['fever', 'swollenglands'] t = threading.Thread(target=diagnose_condition, args=(symptoms)) t.start() t.join() print diagnosis >>> 'mumps' """ global diagnosis from doctor import Doctor d = Doctor('medical.pl') diagnosis = d.diagnose(symptoms, age_group) return
def diagnose_condition(symptoms, age_group=None): """Prevents the segfault from bringing the entire process down. This function *MUST* be run in a background thread. For example: symptoms = ['fever', 'swollenglands'] t = threading.Thread(target=diagnose_condition, args=(symptoms)) t.start() t.join() print diagnosis >>> 'mumps' """ global diagnosis from doctor import Doctor d = Doctor('medical.pl') diagnosis = d.diagnose(symptoms,age_group) return
df = pd.read_csv('./Training.csv') # training data df df_test = pd.read_csv('./Testing.csv') # testing data df #print(df) #print(df_test) # encode prognosis values and store them le = preprocessing.LabelEncoder() le.fit(pd.concat([df['prognosis'], df_test['prognosis']])) encoded_prognosis = le.transform(df['prognosis']) # initialize and train doctor doctor = Doctor() doctor.train(df) # get diagnosis with testing data y_diagnosis = doctor.diagnose(df_test[df_test.columns.difference(['prognosis' ])]) y_pred = [ diagnosis_entry["diagnosis_code"] for diagnosis_entry in y_diagnosis ] # predicted encoded diagnosis values y_proba = [diagnosis_entry["probability"] for diagnosis_entry in y_diagnosis ] # probability vakues for each preciction # compare your prediction with actual values y_true = doctor.diagnosis_encoder.transform(df_test['prognosis']) print("Accuracy:", metrics.accuracy_score(y_true, y_pred)) print("Classification Report:") print(classification_report(y_true, y_pred, target_names=df_test['prognosis'])) print("\nTesting Data Results") test_res = []