| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| import tensorflow as tf |
| import numpy as np |
| import gradio as gr |
| import joblib |
| from sklearn.preprocessing import StandardScaler |
|
|
| |
| model = tf.keras.models.load_model("PRK_BC_NN_Model.keras") |
|
|
| |
| scaler = joblib.load("PRK_BC_NN_Scaler.pkl") |
|
|
| |
| def predict(input_text): |
| |
| input_data = np.array([list(map(float, input_text.split(",")))]) |
|
|
| |
| if input_data.shape != (1, 30): |
| return "Error: Please enter exactly 30 numerical values separated by commas." |
|
|
| |
| input_data_scaled = scaler.transform(input_data) |
| |
| |
| prediction = model.predict(input_data_scaled) |
|
|
| |
| result = "Malignant" if prediction[0][0] > 0.5 else "Benign" |
|
|
| return f"Prediction: {result} (Confidence: {prediction[0][0]:.2f})" |
| |
|
|
| import gradio as gr |
|
|
| |
| iface = gr.Interface( |
| fn=predict, |
| inputs=gr.Textbox(label="Enter 30 feature values, comma-separated"), |
| outputs="text", |
| title="Breast Cancer Prediction", |
| description="Enter 30 numerical feature values separated by commas to predict whether the biopsy is Malignant or Benign." |
| ) |
|
|
| |
| footer = gr.Markdown(""" |
| To test the Model, please copy the data from the original article, excluding the first two data points. <br> |
| For convenience, the data is reproduced here: <br> |
| 17.99,10.38,122.8,1001,0.1184,0.2776,0.3001,0.1471,0.2419,0.07871,1.095,0.9053,8.589,153.4,0.006399,0.04904,0.05373,0.01587,0.03003,0.006193,25.38,17.33,184.6,2019,0.1622,0.6656,0.7119,0.2654,0.4601,0.1189 <br> |
| The original article - |
| <a href="https://prakashkota.com/2025/02/11/the-power-of-machine-learning-in-medical-diagnosis-breast-cancer-mini-case-using-neural-networks/" target="_blank"> |
| The Power of Machine Learning in Medical Diagnosis – Breast Cancer Mini Case using Neural Networks</a> |
| """) |
|
|
| |
| with gr.Blocks() as demo: |
| iface.render() |
| footer.render() |
|
|
| |
| if __name__ == "__main__": |
| demo.launch(share=True) |
|
|
| |
| |
| |
|
|
|
|
| |