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(cm)", 0.0, 10.0, 0.1) sepal_width = st.slider("Sepal_width(cm)", 0.0, 10.0, 0.1) petal_length = st.slider("Petal_length(cm)", 0.0, 10.0, 0.1) petal_width = st.slider("Petal_width(cm)", 0.0, 10.0, 0.1) # 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] == 0: result = "Iris-setosa" elif result[0] == 1: result = "Iris-versicolor" else: result = "Iris-virginica" st.success(f"Your predicted class is {result}") if __name__ == "__main__": main()