kuhs commited on
Commit
94bc2c3
·
verified ·
1 Parent(s): 4132559

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +38 -0
  2. iris_random_forest_classifier.pkl +3 -0
  3. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # %%
2
+ import gradio as gr
3
+ import pandas as pd
4
+ from sklearn.datasets import load_iris
5
+ import pickle
6
+
7
+ # Load model from file
8
+ model_filename = "iris_random_forest_classifier.pkl"
9
+ with open(model_filename, mode="rb") as f:
10
+ model = pickle.load(f)
11
+ # Load dataset
12
+ iris = load_iris(as_frame=True)
13
+
14
+ def predict(sepal_length, sepal_width, petal_length, petal_width):
15
+ input_data = pd.DataFrame([[sepal_length, sepal_width, petal_length, petal_width]],
16
+ columns=iris.feature_names)
17
+ prediction = model.predict(input_data)[0]
18
+ return iris.target_names[prediction]
19
+
20
+ demo = gr.Interface(
21
+ fn=predict,
22
+ inputs=[
23
+ gr.Number(label="Sepal Length"),
24
+ gr.Number(label="Sepal Width"),
25
+ gr.Number(label="Petal Length"),
26
+ gr.Number(label="Petal Width"),
27
+ ],
28
+ outputs="text",
29
+ examples=[
30
+ [5.1, 3.5, 1.4, 0.2],
31
+ [6.2, 2.9, 4.3, 1.3],
32
+ [7.7, 3.8, 6.7, 2.2],
33
+ ],
34
+ title="Iris Flower Prediction",
35
+ description="Enter the sepal and petal measurements to predict the Iris species."
36
+ )
37
+
38
+ demo.launch()
iris_random_forest_classifier.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:07d4e40fbeac348ef6be4f4ff0cce510e878b7e679b75ae0e56b159485dfcea1
3
+ size 177202
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ scikit-learn