-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiris_app.py
55 lines (43 loc) · 1.26 KB
/
iris_app.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import streamlit as st
import pandas as pd
import joblib
from PIL import Image
# Loading Our final trained Knn model
modeltri = open("Knn_Classifier.pkl", "rb")
knn_clf = joblib.load(model)
st.title("Iris flower species Classification App")
# Loading images
setosa = Image.open("setosa.png")
versicolor = Image.open("versicolor.png")
virginica = Image.open("virginica.png")
st.sidebar.title("Features")
# Intializing
parameter_list = [
"Sepal length (cm)",
"Sepal Width (cm)",
"Petal length (cm)",
"Petal Width (cm)",
]
parameter_input_values = []
parameter_default_values = ["5.2", "3.2", "4.2", "1.2"]
values = []
# Display
for parameter, parameter_df in zip(parameter_list, parameter_default_values):
values = st.sidebar.slider(
label=parameter,
key=parameter,
value=float(parameter_df),
min_value=0.0,
max_value=8.0,
step=0.1,
)
parameter_input_values.append(values)
input_variables = pd.DataFrame(
[parameter_input_values], columns=parameter_list, dtype=float
)
st.write("\n\n")
if st.button("Click Here to Classify"):
prediction = knn_clf.predict(input_variables)
st.image(setosa) if prediction == 0 else st.image(
versicolor
) if prediction == 1 else st.image(virginica)