This project demonstrates a simple sales forecasting model using Linear Regression. It predicts total sales based on factors like price per unit, units sold, and operating profit.
.
├── README.md
├── app.py
├── data
│ ├── Adidas_US_Sales_Cleaned.csv
│ └── linear_regression_model.pkl
├── model.ipynb
├── requirements.txt
├── static
│ ├── app.js
│ └── style.css
└── templates
└── index.html
Data Source: https://www.kaggle.com/datasets/heemalichaudhari/adidas-sales-dataset
The dataset used in this project is Adidas_US_Sales_Cleaned.csv
, which contains the following key columns:
- Price per Unit: Price of a single unit of a product.
- Units Sold: Number of units sold.
- Operating Profit: Profit generated from operations.
- Total Sales: The target variable for prediction, representing the total sales amount.
The model used is a Linear Regression model, which aims to predict Total Sales
based on the features Price per Unit
, Units Sold
, and Operating Profit
.
The data is split into training and testing sets using an 80-20 split. After training, predictions are made on the test set, and the performance is evaluated using Mean Squared Error (MSE).
-
Load the Dataset: The dataset is read from a CSV file located in the
data
folder.data = pd.read_csv('data/Adidas_US_Sales_Cleaned.csv')
-
Feature Selection: The relevant features for the model are selected:
X = data[['Price per Unit', 'Units Sold', 'Operating Profit']] y = data['Total Sales']
-
Train-Test Split: The data is split into training and testing sets:
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
-
Model Training: The linear regression model is trained on the training data:
model = LinearRegression() model.fit(X_train, y_train)
-
Model Prediction: Predictions are made on the test data:
y_pred = model.predict(X_test)
-
Model Evaluation: The model's performance is evaluated using Mean Squared Error:
mse = mean_squared_error(y_test, y_pred)
-
Model Saving: The trained model is saved as a
.pkl
file usingjoblib
:joblib.dump(model, 'data/linear_regression_model.pkl')
- Mean Squared Error (MSE): The MSE value represents the model's prediction error. The lower the MSE, the better the model's predictions.
- Model Coefficients: The coefficients of the linear regression model show the relationship between the features and the target variable.
Install the required Python packages using the following command:
pip install -r requirements.txt
-
Clone the repository:
git clone https://github.com/Ismat-Samadov/Sales_Forecasting.git
-
Navigate to the project directory:
cd Sales_Forecasting
-
Install the required dependencies:
pip install -r requirements.txt
-
Run the Flask app:
python app.py
-
Open a browser and go to
http://localhost:5000
to use the web interface for sales prediction.