|
import streamlit as st
|
|
import numpy as np
|
|
import pickle
|
|
from sklearn.preprocessing import StandardScaler
|
|
|
|
|
|
with open('iris_classifier_model.pkl', 'rb') as f:
|
|
model = pickle.load(f)
|
|
|
|
|
|
with open('scaler.pkl', 'rb') as f:
|
|
scaler = pickle.load(f)
|
|
|
|
|
|
class_names = ['Setosa', 'Versicolor', 'Virginica']
|
|
|
|
def predict_species(features):
|
|
|
|
features = np.array(features).reshape(1, -1)
|
|
features = scaler.transform(features)
|
|
|
|
|
|
prediction = model.predict(features)
|
|
predicted_species = class_names[prediction[0]]
|
|
return predicted_species
|
|
|
|
|
|
st.title("Iris Species Classifier")
|
|
st.write("Enter the features of the Iris flower to classify its species:")
|
|
|
|
|
|
sepal_length = st.number_input('Sepal Length (cm)', min_value=0.0, max_value=10.0, value=5.0)
|
|
sepal_width = st.number_input('Sepal Width (cm)', min_value=0.0, max_value=10.0, value=3.0)
|
|
petal_length = st.number_input('Petal Length (cm)', min_value=0.0, max_value=10.0, value=4.0)
|
|
petal_width = st.number_input('Petal Width (cm)', min_value=0.0, max_value=10.0, value=1.0)
|
|
|
|
|
|
if st.button('Predict'):
|
|
features = [sepal_length, sepal_width, petal_length, petal_width]
|
|
species = predict_species(features)
|
|
st.write(f'The predicted species is: **{species}**') |