File size: 1,611 Bytes
3d2fc57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# -*- 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()