import joblib import pandas as pd import streamlit as st model = joblib.load('model_tree.joblib') unique_values = joblib.load('unique_value.joblib') unique_cap-shape = unique_values['cap-shape'] unique_cap-surface = unique_values["cap-surface"] unique_cap-color = unique_values["cap-color"] unique_bruises = unique_values["bruises"] unique_odor = unique_values["odor"] unique_gill-attachment = unique_values["gill-attachment"] unique_gill-spacing = unique_values["gill-spacing"] unique_gill-size = unique_values["gill-size"] unique_gill-color = unique_values['gill-color'] unique_stalk-shape = unique_values["stalk-shape"] unique_stalk-root = unique_values["stalk-root"] unique_stalk-surface-above-ring = unique_values["stalk-surface-above-ring"] unique_stalk-surface-below-ring = unique_values["stalk-surface-below-ring"] unique_stalk-color-above-ring = unique_values["stalk-color-above-ring"] unique_stalk-color-below-ring = unique_values["stalk-color-below-ring"] unique_veil_type = unique_values["veil-type"] unique_veil-color = unique_values['veil-color'] unique_ring-number = unique_values["ring-number"] unique_ring_type = unique_values["ring-type"] unique_spore_print-color = unique_values["spore-print-color"] unique_population = unique_values["population"] unique_habitat = unique_values["habitat"] def main(): st.title("Is this mushroom eatable") with st.form("questionaire"): cap_shape = st.selectbox("cap shape",option = unique_cap-shape) cap_surface = st.selectbox("cap surface",option = unique_cap-surface) cap-color = st.selectbox("cap color",option = unique_cap-color) bruises = st.selectbox("bruises",option = unique_bruises) odor = st.selectbox("odor",option = unique_odor) gill-attachment = st.selectbox("gill attachment",option = unique_gill-attachment) gill-spacing = st.selectbox("gill spacing",option = unique_gill-spacing) gill-size = st.selectbox("gill size",option = unique_gill-size) gill-color = st.selectbox("gill color",option = unique_gill-color) stalk-shape = st.selectbox("stalk shape",option = unique_stalk-shape) stalk-shape = st.selectbox("stalk shape",option = unique_stalk-shape) stalk-root = st.selectbox("stalk root",option = unique_stalk-root) stalk-surface-above-ring = st.selectbox("stalk surface above ring",option = unique_stalk-surface-above-ring) stalk-surface-below-ring = st.selectbox("stalk surface below ring",option = unique_stalk-surface-below-ring) stalk-color-above-ring = st.selectbox("stalk color above ring",option = unique_stalk-color-above-ring) stalk-color-below-ring = st.selectbox("stalk color below ring",option = unique_stalk-color-below-ring) veil_type = st.selectbox("veil type",option = unique_veil_type) veil-color = st.selectbox("veil color",option = unique_veil-color) ring-number = st.selectbox("ring number",option = unique_ring-number) ring_type = st.selectbox("ring type",option = unique_ring_type) spore_print-color = st.selectbox("spore print color",option = unique_unique_spore_print-color) population = st.selectbox("population",option = unique_population) habitat = st.selectbox("habitat",option= unique_habitat) clicked = st.form_submit_button("Predict income") if clicked: 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]})) # Show prediction result = 'eatable' if result[0]==1 else 'poisonous' st.success("This Mushroom is "+result) # Run main() if __name__=="__main__": main()