☕ Cafe Sales — Random Forest Regressor
A tuned Random Forest Regressor trained on cafe transaction data to predict Total Spent per transaction.
📊 Dataset
🧠 Features Used
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%)
🚀 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