Spaces:
Runtime error
Runtime error
Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import joblib
|
2 |
+
import pandas as pd
|
3 |
+
import streamlit as st
|
4 |
+
|
5 |
+
model = joblib.load('model_tree.joblib')
|
6 |
+
unique_values = joblib.load('unique_value.joblib')
|
7 |
+
|
8 |
+
unique_cap-shape = unique_values['cap-shape']
|
9 |
+
unique_cap-surface = unique_values["cap-surface"]
|
10 |
+
unique_cap-color = unique_values["cap-color"]
|
11 |
+
unique_bruises = unique_values["bruises"]
|
12 |
+
unique_odor = unique_values["odor"]
|
13 |
+
unique_gill-attachment = unique_values["gill-attachment"]
|
14 |
+
unique_gill-spacing = unique_values["gill-spacing"]
|
15 |
+
unique_gill-size = unique_values["gill-size"]
|
16 |
+
unique_gill-color = unique_values['gill-color']
|
17 |
+
unique_stalk-shape = unique_values["stalk-shape"]
|
18 |
+
unique_stalk-root = unique_values["stalk-root"]
|
19 |
+
unique_stalk-surface-above-ring = unique_values["stalk-surface-above-ring"]
|
20 |
+
unique_stalk-surface-below-ring = unique_values["stalk-surface-below-ring"]
|
21 |
+
unique_stalk-color-above-ring = unique_values["stalk-color-above-ring"]
|
22 |
+
unique_stalk-color-below-ring = unique_values["stalk-color-below-ring"]
|
23 |
+
unique_veil_type = unique_values["veil-type"]
|
24 |
+
unique_veil-color = unique_values['veil-color']
|
25 |
+
unique_ring-number = unique_values["ring-number"]
|
26 |
+
unique_ring_type = unique_values["ring-type"]
|
27 |
+
unique_spore_print-color = unique_values["spore-print-color"]
|
28 |
+
unique_population = unique_values["population"]
|
29 |
+
unique_habitat = unique_values["habitat"]
|
30 |
+
|
31 |
+
def main():
|
32 |
+
st.title("Is this mushroom eatable")
|
33 |
+
with st.form("questionaire"):
|
34 |
+
cap_shape = st.selectbox("cap shape",option = unique_cap-shape)
|
35 |
+
cap_surface = st.selectbox("cap surface",option = unique_cap-surface)
|
36 |
+
cap-color = st.selectbox("cap color",option = unique_cap-color)
|
37 |
+
bruises = st.selectbox("bruises",option = unique_bruises)
|
38 |
+
odor = st.selectbox("odor",option = unique_odor)
|
39 |
+
gill-attachment = st.selectbox("gill attachment",option = unique_gill-attachment)
|
40 |
+
gill-spacing = st.selectbox("gill spacing",option = unique_gill-spacing)
|
41 |
+
gill-size = st.selectbox("gill size",option = unique_gill-size)
|
42 |
+
gill-color = st.selectbox("gill color",option = unique_gill-color)
|
43 |
+
stalk-shape = st.selectbox("stalk shape",option = unique_stalk-shape)
|
44 |
+
stalk-shape = st.selectbox("stalk shape",option = unique_stalk-shape)
|
45 |
+
stalk-root = st.selectbox("stalk root",option = unique_stalk-root)
|
46 |
+
stalk-surface-above-ring = st.selectbox("stalk surface above ring",option = unique_stalk-surface-above-ring)
|
47 |
+
stalk-surface-below-ring = st.selectbox("stalk surface below ring",option = unique_stalk-surface-below-ring)
|
48 |
+
stalk-color-above-ring = st.selectbox("stalk color above ring",option = unique_stalk-color-above-ring)
|
49 |
+
stalk-color-below-ring = st.selectbox("stalk color below ring",option = unique_stalk-color-below-ring)
|
50 |
+
veil_type = st.selectbox("veil type",option = unique_veil_type)
|
51 |
+
veil-color = st.selectbox("veil color",option = unique_veil-color)
|
52 |
+
ring-number = st.selectbox("ring number",option = unique_ring-number)
|
53 |
+
ring_type = st.selectbox("ring type",option = unique_ring_type)
|
54 |
+
spore_print-color = st.selectbox("spore print color",option = unique_unique_spore_print-color)
|
55 |
+
population = st.selectbox("population",option = unique_population)
|
56 |
+
habitat = st.selectbox("habitat",option= unique_habitat)
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
clicked = st.form_submit_button("Predict income")
|
61 |
+
if clicked:
|
62 |
+
result=model.predict(pd.DataFrame({'cap-shape':[cap_shape],'cap-surface':[cap_surface],'cap-color':[cap-color], 'bruises':[bruises], 'odor':[odor], 'gill-attachment':[gill-attachment], 'gill-spacing':[gill-spacing], 'gill-size':[gill-size], 'gill-color':[gill-color], 'stalk-shape':[stalk-shape], 'stalk-root':[stalk-root], 'stalk-surface-above-ring':[stalk-surface-above-ring], 'stalk-surface-below-ring':[stalk-surface-below-ring], 'stalk-color-above-ring':[stalk-color-above-ring], 'stalk-color-below-ring':[stalk-color-below-ring], 'veil-type':[veil_type], 'veil-color':[veil-color], 'ring-number':[ring-number], 'ring-type':[ring_type], 'spore-print-color':[spore_print-color], 'population':[population], 'habitat':[habitat]}))
|
63 |
+
# Show prediction
|
64 |
+
result = 'eatable' if result[0]==1 else 'poisonous'
|
65 |
+
st.success("This Mushroom is "+result)
|
66 |
+
# Run main()
|
67 |
+
if __name__=="__main__":
|
68 |
+
main()
|