CoolFace
Modelpublic

kendrickfff/OJ-Sales-Revenue-Prediction

sourceHugging Facemitupdated 7mo agoView on Hugging Face
0likes
Model Card

OJ Sales ๐ŸŠ Revenue Prediction (Gradient Boosting)

A Gradient Boosting Regressor trained on the OJ Sales dataset from Azure Open Datasets to predict orange juice Revenue based on sales features.

Built and deployed on Microsoft Fabric during METC Online Training #5: "Mempersiapkan Data untuk Model AI di Microsoft Fabric" ๐ŸŠ organized by Microsoft Elevate and Dicoding.

Model Details

PropertyValue
Model TypeGradient Boosting Regressor
Frameworkscikit-learn
TaskTabular Regression
Target VariableRevenue (continuous)
Training PlatformMicrosoft Fabric + MLflow
DatasetOJ Sales (Azure Open Datasets)
Sample Size500 rows (sampled with random_state=1)
Train/Test Split80/20 (random_state=42)

Features (9)

FeatureTypeDescription
QuantityintUnits sold
AdvertintAdvertisement flag (0=No, 1=Yes)
PricefloatUnit price ($)
Brand_encodedintBrand (0=Dominicks, 1=Minute Maid, 2=Tropicana)
Store_encodedintStore ID (label encoded)
YearintYear extracted from WeekStarting
MonthintMonth (1-12)
WeekOfYearintWeek number (1-52)
QuarterintQuarter (1-4)

Performance

Best Model: Gradient Boosting

MetricScore
Rยฒ0.9965
MAE358.00
RMSE454.92
CV Rยฒ (5-fold)0.9964 ร‚ยฑ 0.0008

All Models Compared

ModelRร‚ยฒMAERMSE
Gradient Boosting0.9965358455
XGBoost0.9960380489
Random Forest0.9952412533
Linear Regression0.94741,8352,450

Usage

python
import pickle
import numpy as np

# Load model
with open("model.pkl", "rb") as f:
    model = pickle.load(f)

# Input: [Quantity, Advert, Price, Brand_encoded, Store_encoded, Year, Month, WeekOfYear, Quarter]
sample = np.array([[15000, 1, 2.50, 1, 5, 1992, 6, 24, 2]])
prediction = model.predict(sample)
print(f"Predicted Revenue: ${prediction[0]:,.2f}")

Key Insights

  • โ€”Quantity and Price are the dominant predictors of Revenue
  • โ€”Advertising (Advert=1) shows positive impact on sales quantity
  • โ€”Ensemble models significantly outperform Linear Regression
  • โ€”Model is highly stable with CV std of only 0.0008

Training Details

  • โ€”Hyperparameters: n_estimators=200, learning_rate=0.1, max_depth=5, random_state=42
  • โ€”Cross-Validation: 5-fold with Rยฒ scoring
  • โ€”Experiment Tracking: MLflow on Microsoft Fabric
  • โ€”Deployment: Real-time API endpoint on Microsoft Fabric

Acknowledgments

  • โ€”Microsoft Elevate and Dicoding for organizing METC Online Training #5
  • โ€”Azure Open Datasets ๐ŸŠ for providing the OJ Sales dataset