import streamlit as st import joblib import numpy as np # Load the trained model model = joblib.load('model_wine_binary.pkl') # Streamlit app def main(): st.title('Wine Type Prediction App') st.write('This app predicts whether a wine is red or white based on input features.') # Feature input names feature_names = [ 'Fixed Acidity', 'Volatile Acidity', 'Citric Acid', 'Residual Sugar', 'Chlorides', 'Free Sulfur Dioxide', 'Total Sulfur Dioxide', 'Density', 'pH', 'Sulphates', 'Alcohol' ] # Collect user input user_inputs = {} for feature in feature_names: user_input = st.number_input(feature, min_value=0.0, max_value=200.0, value=0.0, key=feature) user_inputs[feature] = user_input # Add a "Submit" button if st.button('Submit'): # Check if all inputs are zero (no input) if all(v == 0 for v in user_inputs.values()): st.warning("No input provided. Please enter values.") else: # Prepare input for prediction input_data = np.array([[user_inputs[feature] for feature in feature_names]]) # Make prediction prediction = model.predict(input_data) wine_type = "**White Wine**" if prediction[0] == 1 else "**Red Wine**" # Display prediction st.write('Predicted Wine Type:', wine_type) if __name__ == '__main__': main()