DocSrvNyk commited on
Commit
0134561
·
1 Parent(s): d8d002d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from joblib import load
3
+ import numpy as np
4
+
5
+ # Load the trained model
6
+ model = load("ML_Model_CallCorr.joblib")
7
+
8
+ def predict_corrected_calcium(total_calcium, total_protein, albumin):
9
+ # Calculate Albumin to Total Protein Ratio
10
+ atr = albumin / total_protein
11
+
12
+ # Predict the actual calcium value using the model
13
+ predicted_value = model.predict([[total_calcium, atr]])[0]
14
+
15
+ # Return the result string
16
+ return f"The Actual Calcium value with Correction is {predicted_value:.2f}. The model is a RDF Regression Model with a MSE of 0.06 and R-squared of 0.931."
17
+
18
+ # Define the Gradio interface
19
+ interface = gr.Interface(fn=predict_corrected_calcium,
20
+ inputs=[gr.inputs.Number(label="Total Calcium in mg/dL"),
21
+ gr.inputs.Number(label="Total Protein in g/dL"),
22
+ gr.inputs.Number(label="Albumin in g/dL")],
23
+ outputs=gr.outputs.Textbox())
24
+
25
+ interface.launch()