Description Usage Arguments Details Value Examples
View source: R/match_forecast.R
Builds match_forecast_model to forecast match outcomes by performing bagging using two level modeling. The approach takes into account the uncertainty in the inputs to avoid overconfidence of ML models. Since the inputs to a match outcome prediction problem are often uncertain the approach can enhance the predictive performance of ML models.
1 2 3 |
data |
An example of the columns for basketball data:
In the basketball case ID_1 refers to ID of the home team and P2M_1, P3M_1 to the attributes of the home team. ID_2 refers to the ID of away team and P2M_2, P3M_2 to its attributes. y is the outcome of the match. | ||||||||||
input_model_specification |
Specifies the parametric assumptions of object attributes. We can model attributes of objects as independent with uivariate models or as dependent with multivariate models. Four univariate Bayesian models are supported out of the box:
One multivariate Bayesian model is supported:
Multivariate normal model with inverse Wishart prior for covariance matrix
(see How to invoke the models described above?
For independent Bayesian models a string or a list should be passed in as
| ||||||||||
num_models |
Number of models (distributions) to obtain per attribute. Also matches the number of resulting bagged ML models, since each bagged model is obtained on one set of distributions. | ||||||||||
transformation |
Specifies how attribute distributions are transformed
into actual features being fed into ML algorithm. For each of the parametric assumptions
mentioned above mean transformation is supported out of the box. It is invoked by
passing | ||||||||||
weighting |
Optional parameter. A function that uses the TIME attribute if present to weight the prior matches by importance when obtaining attribute distributions. | ||||||||||
get_model |
Function that should build a ML model on one of | ||||||||||
priors |
Optional parameter. Specifies conjugate priors for supported Bayesian models.
List of lists, one for each object. Names in the outer list correspond to object ID's.
The values in the outer lists are lists with names corresponding to attributes and values
to specifications of parameters of attribute prior distributions. The values in the inner lists
depend on the parametric assumption used. See the documentation of supported parametric assumptions
(e.g. | ||||||||||
report_time |
Boolean denoting whether to report the execution time. Default is |
For detailed explanation see the introduction vignette by running:
vignette("introduction", package = "matchForecast")
Structure of class match_forecast_model
containing
properties:
first_level_model: list with keys being instance ID's and values corresponding first level object models
second_level_model: list of length num_models
with each entry being one of the bagged
predictive models
some other implicit parameters (inspect the object for more info)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | # Builds a logistic regression model on a single sampled train data set obtained
# from object models by applying a transformation function (e.g. means)
get_model <- function(data) {
return(glm(y ~ ., family = binomial(link = "logit"), data = data))
}
# Example of a prior specification (basketball example), for an attribute P3A,
# which is a Poisson variable and measures 3-point attempts. Conjugate prior
# for Poisson distribution is gamma distribution with parameters a - scale and
# b - rate
priors_example <- list(
"San Antonio Spurs" =
list(
"P3A" = list(a = 241.2, b = 12.4),
...
),
"Golden State Warriors" =
list(
"P3A" = list(a = 280.9, b = 13.2),
...
),
...
)
# Builds the Match Forecast Model
mf_model <- match_forecast_model(
# Data frame in match-object format
data = data_train,
# Parametric assumption about attributes
input_model_specification = "poisson",
# How many distributions to fit to each attribute
num_models = 100,
# How to build feature vectors from distributions
transformation = "means",
get_model = get_model,
priors = priors_example
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.