# -*- coding: utf-8 -*- """app.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1QDGbOvpwcdGFAUHlqUqKjWG_UkARrh_A """ import joblib import pandas as pd import streamlit as st SPC_DICT = {'setosa': 0, 'versicolor': 1, 'virginica': 2 } model = joblib.load('model.joblib') unique_values = joblib.load('unique_values.joblib') #unique_srecies = unique_values["srecies"] unique_sepal_length = unique_values["sepal_length"] unique_sepal_width = unique_values["sepal_width"] unique_petal_length = unique_values["petal_length"] unique_petal_width = unique_values["petal_width"] def main(): st.title("Iris") with st.form("questionnaire"): sepal_length = st.slider("sepal_length", min_value=0, max_value=20) sepal_width = st.slider("sepal_width", min_value=0, max_value=20) petal_length = st.slider("petal_length", min_value=0, max_value=20) petal_width = st.slider("petal_width", min_value=0, max_value=20) clicked = st.form_submit_button("Predict iris") if clicked: result = model.predict(pd.DataFrame({ "sepal_length": [sepal_length], "sepal_width": [sepal_width], "petal_length": [petal_length], "petal_width": [petal_width] })) result = 'setosa' if result[0] == 0 result = 'versicolor' elif result[0] == 1 else result = 'virginica' st.success('The predicted iris is {}'.format(result)) if __name__ == '__main__': main()