File size: 1,057 Bytes
3c4b4cb
 
 
 
8a1db3f
3c4b4cb
 
8a1db3f
 
3c4b4cb
 
 
 
 
 
f6e3265
3c4b4cb
 
 
68a07d8
3c4b4cb
 
 
 
 
 
 
 
 
 
 
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
# Bismillahir Rahmaanir Raheem
# Almadadh Ya Gause Radi Allahu Ta'alah Anh - Ameen


from joblib import load
import gradio as gr

# Load the trained model
clf = load('iris_decision_tree_model.joblib')

# Import iris dataset for target names
from sklearn import datasets
iris = datasets.load_iris()

# Define the prediction function
def predict_iris(sepal_length, sepal_width, petal_length, petal_width):
    prediction = clf.predict([[sepal_length, sepal_width, petal_length, petal_width]])
    return iris.target_names[int(prediction[0])]


# Create and launch the Gradio interface
interface = gr.Interface(
    fn=predict_iris, 
    inputs=["number", "number", "number", "number"], 
    outputs="text",
    live=True,
    title="Iris Flower Model",
    description="An introductory example of machine learning in Python. An iris flower model trained on the iris flower dataset using the decision tree algorithm. The accuracy of the model is: 97.37%. Input the dimensions of the iris flower's sepal and petal to predict its species."
)

interface.launch()