# Forecasting ticket sales and city

I am learning data science. I have the following dataset for train tickets:

1. order_date_meduim

order,date,medium
95062,2017-09-11,35
171081,2017-07-05,39
122867,2017-08-18,39
107186,2017-11-23,
171085,2017-09-02,

2. order_ordercityA_ordercityB [some order has only 1 ordercity, I think ordercity means here which city is something like source and destination]

order,ordercityA,ordercityB
81773,4,11
105838,4,
76153,24,18
93058,12,
11623,24,3
3070,24,3

3. order_ticketcount,ticketclass

order,ticketcount,ticketclass
246783,1,pax
1693998,2,pax
1958576,1,other
673681,1,pax
1593899,1,pax
194035,1,pax


I need to forecast the ticket sales for a week and also the ordercity with medium of booking.

As I am new, could someone give a possible answer about how to create a prediction model that could predict the sales for 1 week? Also, I doubt the data is time-series data.

I code in Python.

• Yes it's timeseries; work on adding more features to the data which you think could help the model to strengthen its preds.add various statistics and groupby cols, check for holidays and all, weekends, hour etc, etc and I truly recommend not to jump into Time series first without having proper aspect of ML or hands on experience on various datasets/comps/hacks Mar 10 '19 at 2:53

## 3 Answers

You have got yourself a time series forecasting problem. And with multiple input variables it is called multivariate time series forecasting.

What Is Time Series Forecasting?

You can start with EDA on your data and find out if you can see any trend or seasonality. ( You might need to add or update your current features to get underlying trend/seasonality )

After EDA, you can start looking into following models, all of them are the go-to for time series prediction problem:

• Classical, Statistical
• ARMA for stationary data
• ARIMA for data with a trend - Refer
• SARIMA for data with seasonality
• Holt-Winters Forecasting - Refer
• Theta method - Refer
• Fourier Transformation - Refer
• Machine Learning
• Quantile Regression Forest(QRF)
• Support Vector Regression(SVR)
• Recurrent Neural Networks(RNNs) (LSTM)

If you are not comfortable with Statistics then I would advise you to start with LSTMs for forecasting - Refer

• How to find out the ticketclass or so called categorical column using timeseries forecasting Mar 15 '19 at 17:21
• This is an exact duplicate of another answer you posted. Please customize the answer to the actual question. This is pretty broad as advice. Mar 16 '19 at 20:33

Generally, the first step in modeling is merging all separate datasets into a single dataset. It looks like the data can be joined on order as a key.

Then, sort the data by date.

Next, visualize the data to see general trends and outliers.

The prophet package can estimate forecasts for time series data. A quick-start notebook is here.

• Which join, outer, inner or cartesian product? Mar 12 '19 at 17:25
• Depends on how you want to handle duplicate and missing data. Here is more details jakevdp.github.io/PythonDataScienceHandbook/… Mar 12 '19 at 17:42

The first step is to place all your variables on the same dataframe, so a date row would have a complete set of information for that specific date. The second step is to understand the data and make sure the data make sense. At this stage you have three different data set with a different number of rows. The exact same variable "order" has three different values across the three tables. Does that make sense?

You also have only 5 somewhat random data points. I think with just 5 random data points, you won't have enough information to develop a model that is anymore predictive than a simple average. Train ticket sales is most probably very highly seasonal (vacation, holidays, workweek, commuters, etc.). To do a good model I would venture you need at least a few years of data so you can observe the seasonal pattern from year to year.

If you are just learning data science, I may suggest start with another data set that is a heck of a lot larger than this. Here you have literally nothing to work with.

• I only added the 6 first rows. The dataset is quite big. Mar 17 '19 at 15:49
• There are still a lot of questions with your data set. With three separate variables with different values have exactly the same name "order" how do you know what "order" really means? Mar 18 '19 at 17:19
• It is the order number which is a primary key for those tables. Mar 19 '19 at 16:16