|
|
|
import gradio as gr |
|
import joblib |
|
|
|
|
|
def predict_risk(Age, hOCP, hMisCrg, hHRT, CA125, HE4, FBS, USG): |
|
|
|
model = joblib.load('RDF_OvCa_Final.joblib') |
|
|
|
|
|
input_data = pd.DataFrame({ |
|
'Age': [Age], |
|
'hOCP': [hOCP], |
|
'hMisCrg': [hMisCrg], |
|
'hHRT': [hHRT], |
|
'CA125': [CA125], |
|
'HE4': [HE4], |
|
'FBS': [FBS], |
|
'USG': [USG] |
|
}) |
|
|
|
|
|
probability = model.predict_proba(input_data)[:, 1][0] |
|
|
|
|
|
risk_score = 2 * probability - 1 |
|
|
|
|
|
status = "malignant" if probability >= cutoff else "benign" |
|
|
|
result = f"The OvaCa Risk Score is {risk_score:.2f}. Based on it, the probability is more of {status} ({1 if status == 'malignant' else 0})." |
|
|
|
return result |
|
|
|
|
|
iface = gr.Interface( |
|
fn=predict_risk, |
|
inputs=[ |
|
gr.inputs.Number(label="Age of patient in years"), |
|
gr.inputs.Radio([0, 1], label="History of OCP intake (0: No 1: Yes)"), |
|
gr.inputs.Radio([0, 1], label="History of Miscarriage (0: No 1: Yes)"), |
|
gr.inputs.Radio([0, 1], label="History of HRT (0: No 1: Yes)"), |
|
gr.inputs.Number(label="Serum CA125 level"), |
|
gr.inputs.Number(label="Serum HE4 level"), |
|
gr.inputs.Number(label="Serum Fasting Blood Sugar Level"), |
|
gr.inputs.Radio([0, 1], label="USG Finding (0: Absent or Single Finding 1: More Than 1 Findings)") |
|
], |
|
outputs=gr.outputs.Textbox(label="Result (Risk Score on a Scale of -1 to +1, where >0 ~ Malignant)") |
|
) |
|
|
|
|
|
iface.launch() |
|
|