Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import joblib | |
| import numpy as np | |
| import os | |
| import zipfile | |
| # Unzip the model file to current dir | |
| if not os.path.exists("linear_model.pkl") and os.path.exists("model.zip"): | |
| with zipfile.ZipFile("model.zip", "r") as zip_ref: | |
| zip_ref.extractall() | |
| # Load the model | |
| model = joblib.load("linear_model.pkl") | |
| # ✅ Streamlit UI | |
| st.set_page_config(page_title="ML Model Predictor", layout="centered") | |
| st.title("📊 Linear Regression Predictor") | |
| st.markdown("Enter feature values to get a prediction from your trained model.") | |
| # ✅ Update this to match your model's expected input features | |
| num_features = 12 | |
| inputs = [] | |
| for i in range(num_features): | |
| val = st.number_input(f"Feature {i+1}", value=0.0) | |
| inputs.append(val) | |
| if st.button("Predict"): | |
| input_array = np.array(inputs).reshape(1, -1) | |
| prediction = model.predict(input_array)[0] | |
| st.success(f"🔮 Prediction: {prediction}") |