Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
# Load the dataset from the uploaded CSV file
|
| 5 |
+
df = pd.read_csv("thyroid_disease_data.csv")
|
| 6 |
+
|
| 7 |
+
# Define the function to classify the text
|
| 8 |
+
def classify_thyroid_disease(text):
|
| 9 |
+
# Search the dataset for a matching symptom text (basic string matching)
|
| 10 |
+
result = df[df['text'].str.contains(text, case=False, na=False)]
|
| 11 |
+
|
| 12 |
+
# Return a diagnosis based on the found label
|
| 13 |
+
if not result.empty:
|
| 14 |
+
label = result['label'].iloc[0]
|
| 15 |
+
diagnosis = "Hypothyroidism" if label == 0 else "Hyperthyroidism"
|
| 16 |
+
return diagnosis
|
| 17 |
+
return "No matching diagnosis found."
|
| 18 |
+
|
| 19 |
+
# Create the Gradio interface
|
| 20 |
+
interface = gr.Interface(
|
| 21 |
+
fn=classify_thyroid_disease,
|
| 22 |
+
inputs="text", # User input will be a text field
|
| 23 |
+
outputs="text" # Output will be a text diagnosis
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# Launch the Gradio app
|
| 27 |
+
interface.launch()
|