Spaces:
Runtime error
Runtime error
Upload 3 files
Browse filesInitial deployment: Iris Model with Gradio interface.
- app.py +31 -0
- iris_decision_tree_model.pkl +3 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Bismillahir Rahmaanir Raheem
|
2 |
+
# Almadadh Ya Gause Radi Allahu Ta'alah Anh - Ameen
|
3 |
+
|
4 |
+
|
5 |
+
import pickle
|
6 |
+
import gradio as gr
|
7 |
+
|
8 |
+
# Load the trained model from .pkl file
|
9 |
+
with open('iris_decision_tree_model.pkl', 'rb') as file:
|
10 |
+
clf = pickle.load(file)
|
11 |
+
|
12 |
+
# Import iris dataset for target names
|
13 |
+
from sklearn import datasets
|
14 |
+
iris = datasets.load_iris()
|
15 |
+
|
16 |
+
# Define the prediction function
|
17 |
+
def predict_iris(sepal_length, sepal_width, petal_length, petal_width):
|
18 |
+
prediction = clf.predict([[sepal_length, sepal_width, petal_length, petal_width]])
|
19 |
+
return iris.target_names[int(prediction[0])]
|
20 |
+
|
21 |
+
# Create and launch the Gradio interface
|
22 |
+
interface = gr.Interface(
|
23 |
+
fn=predict_iris,
|
24 |
+
inputs=["number", "number", "number", "number"],
|
25 |
+
outputs="text",
|
26 |
+
live=True,
|
27 |
+
title="Iris Flower Model",
|
28 |
+
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."
|
29 |
+
)
|
30 |
+
|
31 |
+
interface.launch()
|
iris_decision_tree_model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:278efa90d037ad357b233c676e73cbe6da6427c96fc5bcf3afb629c5e3beed19
|
3 |
+
size 2273
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
numpy
|
2 |
+
pandas
|
3 |
+
sklearn
|
4 |
+
gradio
|