I'm trying to make a predictive model that can predict how well a product will sell in the future based on certain parameters. I've made some visualizations showing the relationship between the data. The visualization shows that there's a clear relationship between how warm it is outside and the amount of sales for a certain product.

I have 10 years worth of data for how much a product sold each week along with the temperature for each week. If I split the data, so I only have 8 years worth of data for how much it sold and keep the 10 years data of temperature, what ML algorithm would be best to use to predict the last 2 years of amount of sales?


This seems like a typical time series problem. As you haven't provided much detail about your specific data and what other variables you have information about, I'll just describe one general approach.

First, you should categorize your variables. You have temperature data as a predictor/independent variable. Assuming you have the degree value of the temperature, your variable is numeric - which means you could treat it as a continuous variable. You could instead process your data and turn this into a ordinal categorical variable - but this would require you to select a threshold temperature $T_{0}$, and declare temperatures below $T_{0}$ to be 'cold' and temperature above $T_{0}$ to be 'hot'. Of course, you could also split up the temperature scale into more than one category if you thought a binary categorization lost too much information of value. And, of course, your decision for what value to use as $T_{0}$ will influence the predictive value of this transformation.

Now, for what other variables do you have data? Considering the other variables, you should attempt to distinguish between seasonal variability and short term change. For instance, is it really temperature that is affecting sales, or is it specific seasons of the year that are driving the change in sales? If there is an anomalously warm few days in the middle of winter, comparable to a typical few days in spring or early autumn, do sales really return to the range in those seasons, or not? I would think that the type of item being sold would have some affect on this, so your answer may vary- but also I would guess that seasonal variation plays a bigger role than day-to-day temperature.

Also, is there a long term trend, independent of seasonal or short term change? Can you see a steady change in sales from year to year? Do winter sales from year to year show a long term change that goes beyond the seasonal variation?

This is one way to handle time series - there are other methods, but you would need to provide more information or do further exploratory data analysis to determine which methods are most appropriate. If you haven't encountered time series before, the Wikipedia page is a good place to start: https://en.wikipedia.org/wiki/Time_series


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.