File size: 1,254 Bytes
92e1e29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import pickle

st.title("--Insert title here--")

# Step 1 - import saved model
model = pickle.load(open("milk_pred.pkl", "rb"))

st.write('Insert feature to predict')

# Step 2 - prepare input data for user
ph = st.slider(label='pH', min_value=3.0, max_value=9.5, value=6.5, step=0.1)
temp = st.slider(label='Temprature', min_value=34, max_value=90, value=40, step=1)
taste = st.selectbox(label='Taste', options=['Good', 'Bad'], key=1)
odor = st.selectbox(label='Odor', options=['Good', 'Bad'])
fat = st.selectbox(label='Fat', options=['High', 'Low'])
turb = st.selectbox(label='Turbidity', options=['High', 'Low'])
color = st.number_input(label='Colour', min_value=240, max_value=255, value=245, step=1)

# convert into dataframe
data = pd.DataFrame({'pH': [ph],
                'Temprature': [temp],
                'Taste': [taste],
                'Odor':[odor],
                'Fat': [fat],
                'Turbidity': [turb],
                'Colour': [color]
                })
st.write(data)
# model predict
clas = model.predict(data).tolist()[0]

# interpretation
st.write('Classification Result: ')
if clas == 0:
    st.text('Low')
elif clas == 1:
    st.text('Medium')
else:
    st.text('High')