File size: 1,050 Bytes
db38930
0b349f0
 
2b04b62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
os.system("pip install joblib scikit-learn")


import gradio as gr
import joblib
import numpy as np

# Load the trained model
model = joblib.load("iris_decision_tree.pkl")

# Prediction function
def predict_species(sepal_length, sepal_width, petal_length, petal_width):
    input_data = np.array([[sepal_length, sepal_width, petal_length, petal_width]])
    prediction = model.predict(input_data)[0]
    species = ["setosa", "versicolor", "virginica"]
    return f"The predicted Iris species is: 🌸 {species[prediction]}"

# Gradio interface
iface = gr.Interface(
    fn=predict_species,
    inputs=[
        gr.Number(label="Sepal Length (cm)"),
        gr.Number(label="Sepal Width (cm)"),
        gr.Number(label="Petal Length (cm)"),
        gr.Number(label="Petal Width (cm)")
    ],
    outputs=gr.Textbox(label="Prediction"),
    title="Iris Flower Species Predictor",
    description="Enter flower measurements to predict its species using a Decision Tree model."
)

# Launch the app
if __name__ == "__main__":
    iface.launch()