E25 / app.py
Riya1217's picture
Upload 4 files
9f13c18 verified
import streamlit as st
import pandas as pd
import joblib
# Load the trained pipeline and label encoder
pipeline = joblib.load('xgb_pipeline.joblib')
le = joblib.load('label_encoder.joblib')
st.title('Cheese Milk Type Classifier')
# Dropdown options (customize as needed)
country = st.selectbox('Country', [
'France', 'Italy', 'Switzerland', 'United States', 'Germany',
'Spain', 'England', 'Australia', 'Canada', 'Greece'
])
texture = st.selectbox('Texture', [
'creamy', 'firm', 'crumbly', 'smooth', 'hard', 'soft', 'dense',
'elastic', 'dry', 'buttery', 'mild', 'open'
])
rind = st.selectbox('Rind', [
'natural', 'washed', 'none', 'ash coated', 'leaf wrapped', 'Unknown'
])
vegetarian = st.selectbox('Vegetarian Status', ['True', 'False'])
flavor = st.selectbox('Flavor', [
'nutty', 'mild', 'sweet', 'earthy', 'fruity', 'acidic', 'buttery',
'smokey', 'full-flavored', 'salty', 'creamy', 'sharp', 'bitter', 'Unknown'
])
input_df = pd.DataFrame({
'country': [country],
'texture': [texture],
'rind': [rind],
'vegetarian': [vegetarian],
'flavor': [flavor]
})
# Only ONE button, with a unique key
if st.button('Predict', key='predict_button'):
pred_int = pipeline.predict(input_df)[0]
pred_label = le.inverse_transform([pred_int])[0]
st.write(f'Predicted Milk Type: {pred_label}')