File size: 851 Bytes
e6a3d91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import pickle

# Load Model
model = pickle.load(open('logreg_model.pkl', 'rb'))

st.title('Iris Variety Prediction')

# Form
with st.form(key='form_parameters'):
  sepal_length = st.slider('Sepal Length', 4.0, 8.0, 4.0)
  sepal_width = st.slider('Sepal Width', 2.0, 4.5, 2.0)
  petal_length = st.slider('Petal Length', 1.0, 7.0, 1.0)
  petal_width = st.slider('Petal Width', 0.1, 2.5, 0.1)
  st.markdown('---')

  submitted = st.form_submit_button('Predict')

# Data Inference
data_inf = {
    'sepal.length': sepal_length,
    'sepal.width': sepal_width,
    'petal.length': petal_length,
    'petal.width': petal_width
}

data_inf = pd.DataFrame([data_inf])
if submitted:
    # Predict using Logistic Regression
    y_pred_inf = model.predict(data_inf)

    st.write('## Iris Variety = '+ str(y_pred_inf))