ML Assignment 3 – Maha Qaiser

Dataset: California Housing from sklearn.datasets

File Description

  • best_model.joblib: Mini-Batch Linear Regression model
  • scaler.joblib: StandardScaler object to preprocess input features
  • inference.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)
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support