The objective here is to train a LSTM model to predict a company’s product demands based on their historical data. As per usual we need to gather the proper data to train our model with which in this case we wrote a CSV generator function including 4 columns; one for date and the rest for costumer demands related to 3 products. Now for our main script we load the data generated in the previous step then make it into a sequence for our LSTM model input. We build the LSTM model afterward and pass ‘relu’ as activation function. Then we move forward to training the model with the sequence created in step 2 store its predictions and at last we visualize the data with date-demand plots. We can also change the model’s activation function back to its default value which is ‘tanh’ and compare the results. as you can see in the figure-4 (product1(tanh)) the hit points are a bit wider compared to ‘relu’ and we might get more accurate results in different cases for example if the data appears in wider ranges.

Health Predict
April 29, 2025