Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,31 +5,30 @@ import streamlit as st
|
|
5 |
|
6 |
model = joblib.load('model_XG.joblib')
|
7 |
unique_values = joblib.load('unique_values_XG.joblib')
|
8 |
-
|
9 |
def main():
|
10 |
st.title("Iris's Class")
|
11 |
-
|
12 |
with st.form("questionaire"):
|
13 |
-
sepal_length = st.slider("Sepal_length",
|
14 |
-
sepal_width = st.slider("Sepal_width",
|
15 |
-
petal_length = st.slider("Petal_length",
|
16 |
-
petal_width = st.slider("Petal_width",
|
17 |
|
18 |
# clicked==True only when the button is clicked
|
19 |
clicked = st.form_submit_button("Predict class")
|
20 |
if clicked:
|
21 |
-
result=model.predict(pd.DataFrame({"
|
22 |
-
"
|
23 |
-
"
|
24 |
-
"
|
25 |
# Show prediction
|
26 |
-
if result[0] ==
|
27 |
-
|
28 |
-
elif result[0] ==
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
32 |
|
33 |
-
st.success("Your predicted class is"+result)
|
34 |
if __name__ == "__main__":
|
35 |
main()
|
|
|
5 |
|
6 |
model = joblib.load('model_XG.joblib')
|
7 |
unique_values = joblib.load('unique_values_XG.joblib')
|
|
|
8 |
def main():
|
9 |
st.title("Iris's Class")
|
10 |
+
|
11 |
with st.form("questionaire"):
|
12 |
+
sepal_length = st.slider("Sepal_length(cm)", 0.0, 10.0, 0.1)
|
13 |
+
sepal_width = st.slider("Sepal_width(cm)", 0.0, 10.0, 0.1)
|
14 |
+
petal_length = st.slider("Petal_length(cm)", 0.0, 10.0, 0.1)
|
15 |
+
petal_width = st.slider("Petal_width(cm)", 0.0, 10.0, 0.1)
|
16 |
|
17 |
# clicked==True only when the button is clicked
|
18 |
clicked = st.form_submit_button("Predict class")
|
19 |
if clicked:
|
20 |
+
result=model.predict(pd.DataFrame({"sepal.length": [sepal_length],
|
21 |
+
"sepal.width": [sepal_width],
|
22 |
+
"petal.length": [petal_length],
|
23 |
+
"petal.width": [petal_width]}))
|
24 |
# Show prediction
|
25 |
+
if result[0] == 0:
|
26 |
+
result = "Iris-setosa"
|
27 |
+
elif result[0] == 1:
|
28 |
+
result = "Iris-versicolor"
|
29 |
+
else:
|
30 |
+
result = "Iris-virginica"
|
31 |
+
st.success(f"Your predicted class is {result}")
|
32 |
|
|
|
33 |
if __name__ == "__main__":
|
34 |
main()
|