Laptop Price Prediction

A regression model that estimates the price of a laptop from its specifications (brand, processor speed, RAM, storage, screen size and weight). It was built as the final project of the Business Data Science course (MN1135), Management Study Program.

Model description

  • Algorithm: Ridge Regression (selected from Linear Regression, Decision Tree, Random Forest and SVR, then tuned with 5-fold Grid Search Cross-Validation)
  • Best parameters: {'alpha': '0.1'}
  • Library: scikit-learn 1.6.1
  • Preprocessing: One-Hot Encoding of Brand (drop_first=True) and standardisation of the five numeric features with StandardScaler (needed by this model: yes).

Dataset

Task type

Regression. The target Price is a continuous number.

Input features

Feature Type Description
Brand categorical (Acer, Asus, Dell, HP, Lenovo) Laptop brand
Processor_Speed float Processor speed (GHz, as given in the source data)
RAM_Size integer RAM size in GB (4, 8, 16 or 32 in the training data)
Storage_Capacity integer Storage in GB (256, 512 or 1000 in the training data)
Screen_Size float Screen size in inches (about 11 to 17 in the training data)
Weight float Laptop weight (about 2 to 5 in the training data)

After encoding, the model receives 9 columns; their exact order is stored in feature_names.joblib.

Performance on the test set (200 laptops)

Metric Value
RMSE (main metric) 179.70
MAE 146.23
MSE 32,291.43
Rยฒ 0.9996

RMSE was chosen as the main metric because it is expressed in price units and penalises large pricing errors more heavily. The price currency is not documented in the source dataset.

How to use

import json
import joblib
import pandas as pd
from huggingface_hub import hf_hub_download

repo_id = "JessHF4/laptop-price-model"

model    = joblib.load(hf_hub_download(repo_id, "model_laptop_price.joblib"))
scaler   = joblib.load(hf_hub_download(repo_id, "scaler.joblib"))
features = joblib.load(hf_hub_download(repo_id, "feature_names.joblib"))
with open(hf_hub_download(repo_id, "metadata.json")) as f:
    meta = json.load(f)

new_laptop = pd.DataFrame([{
    "Brand": "Dell", "Processor_Speed": 3.0, "RAM_Size": 16,
    "Storage_Capacity": 512, "Screen_Size": 14.0, "Weight": 2.5,
}])

row = pd.get_dummies(new_laptop, columns=["Brand"])
row = row.reindex(columns=features, fill_value=0).astype(float)
if meta["needs_scaling"]:
    row[meta["numeric_columns"]] = scaler.transform(row[meta["numeric_columns"]])

print("Predicted price:", model.predict(row)[0])

Limitations

  • In the training data, Storage_Capacity is almost perfectly correlated with Price (r = 0.998) and the other specifications hardly matter, so the model is essentially a storage-to-price converter. Real laptop prices also depend on the CPU generation, GPU, display quality, brand positioning and release date, none of which are in the data.
  • The model is only valid inside the ranges it was trained on (three storage sizes, four RAM sizes). Do not use it for specifications outside those ranges.
  • The data is a single snapshot of 1,000 rows without dates, so price changes over time are not captured, and the currency and units are not documented.
  • The model shows an association with price, not a cause. It does not know costs or margins and should be used as a benchmarking aid, not as an automatic pricing tool.
  • The model must be loaded with a compatible scikit-learn version (see requirements.txt).
  • Errors were only checked per storage size; no check per brand or customer segment has been done.

Author

Final project of the MN1135 Business Data Science course, Management Study Program, Odd Semester 2026/2027.

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