This machine learning model predicts sales for Big Mart outlets using various product and store features. The model utilizes XGBoost regression to provide accurate sales forecasts based on historical data.
The model takes into account the following features:
- Item_Identifier: Unique product ID
- Item_Weight: Weight of product
- Item_Fat_Content: Fat content category (Low Fat/Regular)
- Item_Visibility: Product visibility index in store
- Item_Type: Category of product
- Item_MRP: Maximum Retail Price
- Outlet_Identifier: Unique store ID
- Outlet_Establishment_Year: Year store was established
- Outlet_Size: Size of outlet (Small/Medium/High)
- Outlet_Location_Type: Type of location area
- Outlet_Type: Type of outlet (Grocery Store/Supermarket)
-
Missing Value Treatment:
- Item_Weight: Filled with mean value
- Outlet_Size: Filled using mode based on Outlet_Type
-
Feature Engineering:
- Standardized Item_Fat_Content categories
- All categorical variables encoded using Label Encoding
-
Data Split:
- Training set: 80% of data
- Testing set: 20% of data
- Algorithm: XGBoost Regressor
- Random State: 2
- Default hyperparameters
The model achieved the following performance metrics:
- R-squared score on training data: 0.94
- R-squared score on test data: 0.55
- Python 3.x
- Required libraries:
- numpy
- pandas
- matplotlib
- seaborn
- scikit-learn
- xgboost
- Data Preparation:
# Load and preprocess data
big_mart_data = pd.read_csv('Train.csv')
# Handle missing values and encode categorical features- Model Training:
# Initialize and train the model
regressor = XGBRegressor()
regressor.fit(X_train, Y_train)- Making Predictions:
# Predict sales
predictions = regressor.predict(X_test)- Item_Weight shows a normal distribution
- Item_Visibility has a right-skewed distribution
- Item_MRP shows a multimodal distribution
- Item_Outlet_Sales exhibits right-skewed distribution
- Multiple outlet establishment years represented
- Two main fat content categories: Low Fat and Regular
- Various item types with different frequencies
- Three outlet sizes: Small, Medium, High
- Feature engineering to create more informative variables
- Hyperparameter tuning for better model performance
- Ensemble methods to improve prediction accuracy
- Cross-validation for more robust evaluation
Feel free to fork the repository and submit pull requests. For major changes, please open an issue first to discuss the proposed changes.