Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import joblib
|
3 |
+
import pandas as pd
|
4 |
+
from ucimlrepo import fetch_ucirepo
|
5 |
+
|
6 |
+
# Load the trained model
|
7 |
+
model = joblib.load("model.pkl")
|
8 |
+
|
9 |
+
# Define feature columns
|
10 |
+
FEATURE_COLUMNS = ['radius1', 'texture1', 'perimeter1', 'area1', 'smoothness1',
|
11 |
+
'compactness1', 'concavity1', 'concave_points1', 'symmetry1',
|
12 |
+
'fractal_dimension1', 'radius2', 'texture2', 'perimeter2', 'area2',
|
13 |
+
'smoothness2', 'compactness2', 'concavity2', 'concave_points2',
|
14 |
+
'symmetry2', 'fractal_dimension2', 'radius3', 'texture3', 'perimeter3',
|
15 |
+
'area3', 'smoothness3', 'compactness3', 'concavity3', 'concave_points3',
|
16 |
+
'symmetry3', 'fractal_dimension3']
|
17 |
+
|
18 |
+
# Prediction function
|
19 |
+
def predict(*features):
|
20 |
+
input_data = pd.DataFrame([features], columns=FEATURE_COLUMNS)
|
21 |
+
prediction = model.predict(input_data)
|
22 |
+
return "Malignant" if prediction[0] == 1 else "Benign"
|
23 |
+
|
24 |
+
# Gradio interface
|
25 |
+
iface = gr.Interface(
|
26 |
+
fn=predict,
|
27 |
+
inputs=[gr.Number(label=col) for col in FEATURE_COLUMNS],
|
28 |
+
outputs="text",
|
29 |
+
title="Breast Cancer Diagnosis Predictor",
|
30 |
+
description="Enter the values of the features to predict the diagnosis."
|
31 |
+
)
|
32 |
+
|
33 |
+
if __name__ == "__main__":
|
34 |
+
iface.launch()
|