简体   繁体   中英

Time Series Forecasting in python

I have dataset that contins 300 rows and 4 columns: Date, Hour, counts(how many ads were emitted during this hour in TV), Visits (how many visits were made during this hour). Here is example of data: 在此处输入图像描述

If I want to test the effect of the tv spots on visits on the website, should I treat it as a time series and use regression for example? And what should the input table look like in that case? I know that I have to divide the date into day and month, but how to treat the counts column, leave them as they are, if my y is to be the number of visits? Thanks

just to avoid case of single input and single output regression model, you could use hour and counts as input and predict the visits. I don't know what format are hours in, if they are in 12hrs format convert them to 24hr format before feeding them to your model.

If you want predict the the next dates and hours in the time series, regression models or classical time series model such as ARIMA, ARMA, exponential smoothing would be useful.

But, as you need to predict the effectiveness of tv spot, I recommend to generate features using tsfresh library in python, based on counts to remove the time effect and use a machine learning model to do prediction, such as SVR or Gradient Boosting .

In your problem:

from tsfresh import extract_features
extracted_features = extract_features(df,
                                      column_id="Hour",
                                      column_kind=None,
                                      column_value="Counts",
                                      column_sort="time")

So, your target table will be:

Hour    Feature_1     Feature_2    ...    Visits(Avg)
0      min(Counts)    max(Counts)  ...    mean(Visits)
1      min(Counts)    max(Counts)  ...    mean(Visits)
2      min(Counts)    max(Counts)  ...    mean(Visits)

min() and max() are just example features, tsfresh could extract many other features. Visit here for more information

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM