Screenshot of Sales Prediction using genetic Programming - a sales prediction model using Genetic Programming to forecast sales based on factors such as price,...
lab Python pandas DEAP NumPy Scikit-Learn Matplotlib

Sales Prediction using genetic Programming

Sales Prediction using genetic Programming

A sales prediction model using Genetic Programming to forecast sales based on factors such as price, discount, advertisement, and cost.

Overview

Genetic Programming (GP) is an evolutionary algorithm-based technique for solving optimization problems. In this project, GP is employed to predict sales based on various input features such as price, discount, advertisement, and cost.

Usage

  1. Clone the repository:

    git clone git clone https://github.com/Last-Sage/Genetic-Programming-Forcasting.git
    
  2. Navigate to the project directory:

    cd Genetic-Programming-Forcasting
    
  3. Run the main Python script:

    python Genetic_Programming.py

Importing Data

The training and testing data should be provided in CSV format. Ensure that the file paths to the training and testing data are correctly specified in the script.

Genetic Programming Settings and other Parameter Configuration

ParameterDescription
individual_sizeThe size of each individual in the population.
population_sizeThe size of the population.
generationsThe number of generations for which the genetic algorithm will run.
cxpbCrossover probability.
mutpbMutation probability.
tournsizeTournament size for selection.
file_nameFile path to the CSV file containing training and testing data.
attr_priceRange for generating random values for the ā€˜price’ attribute.
attr_discountRange for generating random values for the ā€˜discount’ attribute.
attr_advertisementRange for generating random values for the ā€˜advertisement’ attribute.
attr_costRange for generating random values for the ā€˜cost’ attribute.

Fitness Function

The fitness function evaluates the performance of each individual in the population based on the mean squared error (MSE) between the predicted and actual sales. The fitness is minimized.

Visualization

visualize_data : Scatter plot of input data for verification.
visualize_predictions : Line plot comparing actual sales with predicted sales.

Results

The script outputs various performance metrics:

MetricDescription
Mean squared error (MSE)The average of the squares of the differences between predicted and actual values.
R-squared valueA statistical measure indicating the proportion of the variance in the dependent variable that is predictable from the independent variables.
Mean absolute error (MAE)The average of the absolute differences between predicted and actual values.
Root mean squared error (RMSE)The square root of the average of the squares of the differences between predicted and actual values.
Mean percentage error (MPE)The average of the percentage differences between predicted and actual values.
Mean absolute percentage error (MAPE)The average of the absolute percentage differences between predicted and actual values.
Root mean squared percentage error (RMSPE)The square root of the average of the squares of the percentage differences between predicted and actual values.
Coefficient of variation (CV)The ratio of the standard deviation to the mean, expressed as a percentage.

Run this project in Google Colab

āš™ļøRun in Google Colab