App_Iris / app.py
akhud's picture
Application Iris Dataset
cda6b4d
raw
history blame
742 Bytes
# app_iris.py
import streamlit as st
import onnxruntime as rt
import numpy as np
# Load the trained ONNX model
sess = rt.InferenceSession("random_forest_iris.onnx")
st.title("Iris Prediction with Random Forest")
# Input features
sepal_length = st.slider("Sepal Length", 0.0, 10.0, 5.0)
sepal_width = st.slider("Sepal Width", 0.0, 10.0, 3.5)
petal_length = st.slider("Petal Length", 0.0, 10.0, 2.5)
petal_width = st.slider("Petal Width", 0.0, 10.0, 1.0)
input_features = [sepal_length, sepal_width, petal_length, petal_width]
# Predict
if st.button("Predict"):
input_array = np.array([input_features], dtype=np.float32)
pred_onnx = sess.run(None, {'float_input': input_array})
st.write(f"Predicted class: {pred_onnx[0][0]}")