DocSrvNyk's picture
Update app.py
70478e1
import gradio as gr
import joblib
# Load the saved model
model = joblib.load('rdf_model.pkl')
# Define the function for prediction
def predict(Age, hPostMen, Parity, hEndoMet, hTubeLig, hOCP, Urea, TG, FBS, AoMen):
# Prepare the input data as a single sample
input_data = [[Age, hPostMen, Parity, hEndoMet, hTubeLig, hOCP, Urea, TG, FBS, AoMen]]
# Get the prediction
prediction = model.predict(input_data)[0]
# Return the result
return f"Predicted probability of detected mass is {'Malignant' if prediction == 1 else 'Benign'}"
# Define the Gradio interface
iface = gr.Interface(
predict,
[
gr.inputs.Number(label="Age (Age in years)"),
gr.inputs.Radio([0, 1], label="Menopause Status: 0 - No, 1 - Yes"),
gr.inputs.Radio([1, 2, 3], label="Parity: 1 - Nulliparous, 2 - Uniparous, 3 - Multiparous"),
gr.inputs.Radio([0, 1], label="History of Endometriosis: 0 - No, 1 - Yes"),
gr.inputs.Radio([0, 1], label="History of Tubal Ligation: 0 - No, 1 - Yes"),
gr.inputs.Radio([0, 1], label="History of OCP usage: 0 - No, 1 - Yes"),
gr.inputs.Number(label="Serum Urea"),
gr.inputs.Number(label="Serum Triglyceride"),
gr.inputs.Number(label="Fasting Blood Sugar"),
gr.inputs.Radio([1, 2, 3], label="Age of Menarche: 1 - <10, 2: 11-13, 3: >13"),
],
gr.outputs.Textbox(label="Prediction"),
)
# Launch the interface
iface.launch()