H&M Fashion Recommendation Model
Model Description
A LightGBM binary classification model converted to ONNX format for personalized fashion recommendations. Built for the H&M Personalized Fashion Recommendations Kaggle competition (MAP@12 metric).
The model predicts whether a customer will purchase a specific article based on 30 engineered features derived from customer behavior, article properties, and transaction history.
Model Details
- Architecture: LightGBM (gradient boosted decision trees)
- Format: ONNX (converted via OnnxMLTools)
- Task: Binary classification (purchase / no-purchase)
- Input: 31 features (float32), shape
[batch_size, 31] - Output:
label: Predicted class (int64)probabilities: Class probability distribution
- Trees: 200 boosting iterations
- Objective: Binary sigmoid
Input Features
The model expects 31 features including:
- Customer demographics (age, club membership, fashion news)
- Article attributes (price, garment group, product type, color, department)
- Transaction-derived features (purchase counts, recency, frequency)
Usage
import onnxruntime as ort
import numpy as np
# Load model
session = ort.InferenceSession("H&MRecommendationSystemModel.onnx")
# Prepare input (shape: [1, 31])
input_data = np.random.rand(1, 31).astype(np.float32)
# Run inference
inputs = {"input": input_data}
label, probabilities = session.run(None, inputs)
print(f"Predicted label: {label[0]}")
print(f"Probabilities: {probabilities}")
Training
- Framework: LightGBM
- Dataset: H&M transaction data (Kaggle)
- Feature Engineering: 15 new features engineered, 11 dropped from raw data
- Cleaning Strategy: Median version (best of 4 strategies tested)
- No image data used (resource constraint)
Limitations
- Trained on H&M-specific data; may not generalize to other retailers
- Does not use image features (tabular only)
- Binary classification per (customer, article) pair — ranking requires post-processing
License
Apache License 2.0