2
$\begingroup$

I have soccer data with a time series index. 30 seconds interval. So, 194 rows for 90+ minutes per game. I have 1500 games. The dataframe has the following information.

Home/Away:

• Goal Total.

• Shots Total.

• Dangerous Attack Total and.

• XG(Expected goal per game) given at the start of the match which needs to be adjusted per section.

I am required to build a time series model to predict time t+1 (say Goal score).

Given that for each variable the graph shows the highest spike in the later stage of the time, Is there any machine learning algorithms that can learn with such a small dataset?

Sample Data

g = pd.DataFrame({'TimeSlot':[0, 30000, 60000, 90000, 120000, 150000, 180000, 210000, 240000, 270000, 300000],
    'xG_A':[1.5]*11, 'xG_B':[1.2]*11, 'A_DAT':[0,1,2,3,4,4,5,5,6,6,7],
    'B_DAT':[0,0,1,1,2,2,2,3,3,3,4],
    'A_ST':[0,0,1,1,2,2,2,3,3,3,3], 'B_ST':[0,0,0,1,1,1,1,2,2,2,2],
    'A_GT':[0,0,0,0,0,0,1,1,1,1,2], 'B_GT':[0,0,0,1,1,1,1,1,1,1,1]})
g.set_index('TimeSlot', inplace=True)

The assumption is only one Goal/Shot can be scored/taken per Timeslot. So the same data per period will look like...

f= pd.DataFrame({'TimeSlot':[0, 30000, 60000, 90000, 120000, 150000, 180000, 210000, 240000, 270000, 300000],
    'xG_A':[1.5]*11, 'xG_B':[1.2]*11, 'A_DATP':[0,1,1,1,1,0,1,0,1,0,1],
    'B_DAP':[0,0,1,0,1,0,0,1,0,0,1],
    'A_STP':[0,0,1,0,1,0,0,1,0,0,0], 'B_STP':[0,0,0,1,0,0,0,1,0,0,0],
    'A_GTP':[0,0,0,0,0,0,1,0,0,0,1], 'B_GTP':[0,0,0,1,0,0,0,0,0,0,0]})
f.set_index('TimeSlot', inplace=True)

***ARIMA(2,1,0) with train, test = X[0:size], X[size:len(X)]
gives MSE:0.323 for g and MSE: 0.291 for f.***

Questions

Which dataframe should I use?

I would really appreciate if someone starts off with a few python codes...

$\endgroup$

3 Answers 3

2
$\begingroup$

This is a typical application of the ARIMA model. By choosing the proper order (p,q and d in the wikipedia page), this model can be trained effectively with relatively small amount of data.

$\endgroup$
1
  • $\begingroup$ please see the edited version. $\endgroup$
    – Abs
    Commented Sep 10, 2018 at 16:56
2
$\begingroup$

Assuming that your general model specification looks like

HAW - Home/Away: GT - Goal Total. ST – Shots Total. DAT – Dangerous Attack Total. XG - XG

GT(t)= function(HAW(t),GT(t-1), GT(t-2),…, GT(t-p1), ST(t-1),ST(t-2),…, ST(t-p2),DAT(t-1),DAT(t-2),…, DAT(t-p3),XG(t)-XG(t-1))+error

(1) If the functional form is not known you can use Neural Network method that can learn from time series (RNN), you can try different lag lengths p1,p2,p3 to see if model improves

(2) If the function is linear then you can apply time series method having lagged dependent variables as well as other drivers that are also time dependent

Because it is a time series model, you should investigate stationarity by taking first difference, testing for unit root to properly identify your model.

$\endgroup$
2
  • $\begingroup$ Does the terms in GT(t) taken from both Home and Away variables? $\endgroup$
    – Abs
    Commented Sep 10, 2018 at 16:55
  • $\begingroup$ I suspect HAW (Home or Away) will be a dummy variable 1=home 0=away, expecting probably that the weight or coefficient for this variable would be positive: when a soccer game is at Home, there are more fan support therefore team is likely to be motivated to win. Also if you are predicting outcome for only current game then the dependent variable could be GT(t)-GT(t-1) for incremental goal in the estimation equation. $\endgroup$
    – okossial
    Commented Sep 11, 2018 at 14:20
1
$\begingroup$

The package you should look at is statsmodel, which has a class ARIMAResults (the model identified by user12075). The documentation is at statsmodels.tsa.arima_model.ARIMAResults and there's also a thread here on its use.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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