|
Download README.md from mahaqj/ml_assignment_3: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/mahaqj/ml_assignment_3/resolve/main/README.md
- Command line
-
hf download hf://mahaqj/ml_assignment_3/README.md
-
curl -L -o README.md https://huggingface.co/mahaqj/ml_assignment_3/resolve/main/README.md
1.72 kB
metadata
license: mit
ML Assignment 3 – Maha Qaiser
Dataset: California Housing from sklearn.datasets
File Description
best_model.joblib: Mini-Batch Linear Regression modelscaler.joblib: StandardScaler object to preprocess input featuresinference.py: Script to load the model + scaler and run predictions with user input
Model Overview
- Model Type: Mini-Batch Linear Regression
- Features Used:
- Avg. Rooms
- Avg. Bedrooms
- Population
- Household
- Median Income
- Latitude
- Longitude
- Housing Median Age
- Regularization: L2 (Ridge)
- Early Stopping: Applied during training
How to Run Inference
1. Clone the repository or download the files:
git clone https://huggingface.co/mahaqj/ml_assignment_3
cd ml_assignment_3
2. Install dependencies:
pip install joblib numpy scikit-learn huggingface_hub
3. Run the script:
python inference.py
You’ll be prompted to enter the following features:
- Avg. Rooms
- Avg. Bedrooms
- Population
- Household
- Median Income
- Latitude
- Longitude
- Housing Median Age
The model will return the predicted housing value.
Loading the Model in Python
import joblib
import requests
from io import BytesIO
# urls to both model and scaler
model_url = "https://huggingface.co/mahaqj/ml_assignment_3/resolve/main/best_model.joblib"
scaler_url = "https://huggingface.co/mahaqj/ml_assignment_3/resolve/main/scaler.joblib"
# download and load model
model_bytes = BytesIO(requests.get(model_url).content)
model = joblib.load(model_bytes)
# download and load scaler
scaler_bytes = BytesIO(requests.get(scaler_url).content)
scaler = joblib.load(scaler_bytes)