IrisPrediction / app.py
Vishnurak's picture
Update app.py
c7b5f81
raw
history blame
1.39 kB
import joblib
import pandas as pd
import streamlit as st
model = joblib.load('model_XG.joblib')
unique_values = joblib.load('unique_values_XG.joblib')
def main():
st.title("Iris's Class")
with st.form("questionaire"):
sepal_length = st.slider("Sepal_length", min_value=0, max_value=6)
sepal_width = st.slider("Sepal_width", min_value=0, max_value=6)
petal_length = st.slider("Petal_length", min_value=0, max_value=6)
petal_width = st.slider("Petal_width", min_value=0, max_value=6)
# clicked==True only when the button is clicked
clicked = st.form_submit_button("Predict class")
if clicked:
result=model.predict(pd.DataFrame({"sepal_length": [sepal_length],
"sepal_width": [sepal_width],
"petal_length": [petal_length],
"petal_width": [petal_width]}))
# Show prediction
if result[0] == 'Iris-setosa':
st.write("Iris-setosa")
elif result[0] == 'Iris-versicolor':
st.write("Iris-versicolor")
elif result[0] == 'Iris-virginica':
st.write("Iris-virginica")
st.success("Your predicted class is"+result[0])
if __name__ == "__main__":
main()