### Product Demand Prediction Project Using Machine Learning

You must have learned that demand for a product change as the price of the product changes. To give a real-life example, if a product is not needed, demand decreases when price increases, and demand increases when price decreases. If you want to know how to use machine learning to predict product demand, this article is for you. This article describes the task of predicting product demand with machine learning using Python.

A product company plans to offer discounts on their products during the upcoming holiday season. The company wants to find a price that makes its product cheaper than its competitors. For this task, the company provided records of historical sales changes based on price changes. I need to train a model that can predict the demand for a product in markets with different price points.

I hope you have understood what kind of question sentences you can get in the product demand forecasting task. In the next section, I’ll show you how to predict product demand with machine learning using Python.

Let’s start by importing the Python libraries and datasets required for the product demand forecasting task.

Let’s get some information and description about our dataset.

Let’s check whether our data contains Null values or not.

So, since there is only one value in the “Total Price” column for this record, here we delete the entire row.

Now let’s analyze the relationship between product price and demand. Here we use a scatterplot to see how demand for a product change with price changes.

It can be seen that, with a few exceptions, most of the data points indicate that product sales increase as prices decrease. Now let’s look at the correlations between the characteristics of the dataset.

## Modelling

Now let’s move on to the task of training a machine learning model to predict demand for a product at various prices. Select the ‘Total Price’ and ‘Base Price’ columns as the functions to train the model on, and the ‘Units Sold’ column as the labels for the model.

Let’s split the data into a training set and a test set and train a model using the decision tree regression algorithm.

Now let’s input the features (Total Price, Base Price) into the model and predict how much quantity can be demanded based on those values:

## Summary

This is how you can use Python to train a machine learning model for the task of predicting product demand. Price is one of the most important factors influencing product demand. If there is no need, few people will buy the product even if the price goes up. I hope you enjoyed this article on predicting product demand with machine learning using Python.