import streamlit as st import pandas as pd from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.linear_model import LogisticRegression from sklearn.metrics import accuracy_score, classification_report, confusion_matrix # Load the dataset df = pd.read_csv('iris.csv') # Prepare data X = df.drop('species', axis=1) y = df['species'] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42) scaler = StandardScaler() X_train = scaler.fit_transform(X_train) X_test = scaler.transform(X_test) # Train the model (only once) logreg = LogisticRegression() logreg.fit(X_train, y_train) # Streamlit app st.title("Iris Flower Classification") st.write("Input the features of the iris flower below:") sepal_length = st.number_input("Sepal Length (cm)", value=5.1) sepal_width = st.number_input("Sepal Width (cm)", value=3.5) petal_length = st.number_input("Petal Length (cm)", value=1.4) petal_width = st.number_input("Petal Width (cm)", value=0.2) if st.button("Predict"): input_data = [[sepal_length, sepal_width, petal_length, petal_width]] input_data = scaler.transform(input_data) prediction = logreg.predict(input_data)[0] st.write(f"Predicted Species: {prediction}")