DocSrvNyk commited on
Commit
2e8b609
·
1 Parent(s): 1323777

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from joblib import load
3
+ import numpy as np
4
+
5
+ # Load the trained XGBoost model
6
+ model = load('Model_SCD_XGB.joblib')
7
+
8
+ def predict_sickle_cell_crisis(Hct, Lymper, Age, JtPainFreq_yr):
9
+ # Prepare the input data as a numpy array
10
+ input_data = np.array([[Hct, Lymper, Age, JtPainFreq_yr]])
11
+
12
+ # Use the model to make a prediction
13
+ prediction = model.predict(input_data)[0]
14
+ prediction_prob = model.predict_proba(input_data)[0]
15
+
16
+ # Calculate the scaled risk score
17
+ risk_score = 2 * prediction_prob[1] - 1
18
+
19
+ # Prepare the result string
20
+ 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."
21
+
22
+ return result_str
23
+
24
+ # Create Gradio Interface
25
+ iface = gr.Interface(
26
+ fn=predict_sickle_cell_crisis,
27
+ inputs=[
28
+ gr.inputs.Number(label="Hematocrit value in %"),
29
+ gr.inputs.Number(label="Lymphocyte % of TLC"),
30
+ gr.inputs.Slider(minimum=0, maximum=120, default=25, label="Age (in years)"), # Slider for Age
31
+ # gr.inputs.Number(label="Hb Haemoglobin in g/dL"),
32
+ gr.inputs.Number(label="Joint Pain Frequency as Counts in past one year"),
33
+ # gr.inputs.Radio([0, 1], label="Any H/O Joint Pain & Swelling in the past one year (1 - Yes, 0 - No)")
34
+ ],
35
+ outputs=gr.outputs.Textbox()
36
+ )
37
+
38
+ iface.launch(inbrowser=True)