dubattim commited on
Commit
3aba5ef
·
verified ·
1 Parent(s): abc7e04

Upload 3 files

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