prediction {BCT}R Documentation

Prediction

Description

Computes the posterior predictive distribution at each time step, and predicts the next symbol as its most likely value. Given an initial context (x-D+1, ..., x0) and training data (x1, ..., xn), the posterior predictive distribution is computed sequentially for the test data (xn+1, ..., xn+T). The function outputs the predicted distribution at each time step, along with the most likely symbol; for more information see Kontoyiannis et al.(2020).

Usage

prediction(input_data, depth, train_size, beta = NULL)

Arguments

input_data

the sequence to be analysed. The sequence needs to be a "character" object. See the examples section on how to transform any dataset to a "character" object.

depth

maximum memory length.

train_size

number of samples used for training.

beta

hyper-parameter of the model prior. Takes values between 0 and 1. If not initialised in the call function, the default value is 1-2-m+1, where m is the size of the alphabet; for more information see: Kontoyiannis et al. (2020).

Value

returns a "list" containing the posterior predictive distribution at each time step. The last entry in the list, named "Prediction", contains the most likely character at each time step according to the posterior predictive distribution.

See Also

log_loss, zero_one_loss

Examples

# Predicting the 2 last characters of a dataset using a model with a maximum depth of 5
# The training size is the total number of characters within the dataset minus 2: nchar(pewee) - 2

q <- prediction(pewee, 5, nchar(pewee) - 2)

q
# [[1]]
# [1] 0.56300039 0.05899728 0.37800233

# [[2]]
# [1] 0.08150306 0.76293065 0.15556628

# $Prediction
# [1] "0" "1"

# To access the "Prediction" from result list q:
q[["Prediction"]]

# For custom beta (e.g. 0.8):
prediction(pewee, 5, nchar(pewee) - 10, 0.8)

[Package BCT version 1.2 Index]