β˜• Cafe Sales β€” Random Forest Regressor

A tuned Random Forest Regressor trained on cafe transaction data to predict Total Spent per transaction.


πŸ“Š Dataset

Property Value
Source Cafe Sales Dataset
Rows 9,540 transactions
Target Total Spent (in currency units)

🧠 Features Used

Feature Type
Item Categorical (Coffee, Cake, Cookie, etc.)
Quantity Numeric
Payment Method Categorical (Cash, Credit Card, Digital Wallet)
Location Categorical (In-store, Takeaway)
Day of Week Numeric (0=Mon, 6=Sun)
Month Numeric (1–12)
Is Weekend Binary (0/1)

Price Per Unit was intentionally dropped to avoid trivial prediction (Total Spent = Qty Γ— PPU).


βš™οΈ Best Hyperparameters (via RandomizedSearchCV, cv=5)

n_estimators      = 300
max_depth         = 10
min_samples_split = 10
min_samples_leaf  = 2
max_features      = 0.5

πŸ“ˆ Evaluation Metrics (Test Set β€” 20%)

Metric Default RF Tuned RF
MAE 0.7800 0.7007
RMSE 1.8726 1.6997
RΒ² 0.8959 0.9142

πŸš€ Usage

import joblib
import pandas as pd
from huggingface_hub import hf_hub_download

# Model download karo
model_path = hf_hub_download(
    repo_id="rohansuyal/cafe-sales-rf-regressor",
    filename="rf_tuned_model.pkl"
)

# Load karo
model = joblib.load(model_path)

# Predict karo
sample = pd.DataFrame([{
    "Item": "Coffee",
    "Quantity": 2.0,
    "Payment Method": "Cash",
    "Location": "In-store",
    "Day_of_Week": 0,
    "Month": 6,
    "Is_Weekend": 0
}])

prediction = model.predict(sample)
print(f"Predicted Total Spent: {prediction[0]:.2f}")

πŸ› οΈ Tech Stack

  • Python 3.10
  • scikit-learn β€” RandomForestRegressor, Pipeline, ColumnTransformer
  • pandas / numpy β€” Data processing
  • joblib β€” Model serialization

πŸ“ Files

File Description
rf_tuned_model.pkl Trained pipeline (preprocessor + model)
README.md This file
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ 1 Ask for provider support