|
import gradio as gr |
|
from joblib import load |
|
import numpy as np |
|
|
|
|
|
model = load('Model_SCD_XGB.joblib') |
|
|
|
def predict_sickle_cell_crisis(Hct, Lymper, Age, JtPainFreq_yr): |
|
|
|
input_data = np.array([[Hct, Lymper, Age, JtPainFreq_yr]]) |
|
|
|
|
|
prediction = model.predict(input_data)[0] |
|
prediction_prob = model.predict_proba(input_data)[0] |
|
|
|
|
|
risk_score = 2 * prediction_prob[1] - 1 |
|
|
|
|
|
result_str = f"The XSCP (XGBoost Sickle-Cell Crisis Prediction) Model predicts the chances of patient going into Sickle Cell Crisis as {'Positive' if prediction == 1 else 'Negative'}, with a scaled probability Risk Score of : {risk_score:.2f}. This trained model has a F1 Accuracy of 1.00 with a 100% Precision and Recall." |
|
|
|
return result_str |
|
|
|
|
|
iface = gr.Interface( |
|
fn=predict_sickle_cell_crisis, |
|
inputs=[ |
|
gr.inputs.Number(label="Hematocrit value in %"), |
|
gr.inputs.Number(label="Lymphocyte % of TLC"), |
|
gr.inputs.Slider(minimum=0, maximum=120, default=25, label="Age (in years)"), |
|
|
|
gr.inputs.Number(label="Joint Pain Frequency as Counts in past one year"), |
|
|
|
], |
|
outputs=gr.outputs.Textbox() |
|
) |
|
|
|
iface.launch() |
|
|