Base class for Adaptive discrete smoothing.

Format

R6::R6Class object.

Active bindings

data

(data.frame())
Data frame.

learner

(LearnerRegr)
A learner.

task_list

(list())
A list of tasks.

learner_list

(list())
A list of learners.

delta

(numeric())
A vector.

gamma

(numeric())
A vector.

weight_path

(array())
An array.

predictions

(array())
An array.

Methods

Public methods


Method new()

Initialize a ADS Class object.

Usage

ADS$new(
  data,
  target,
  individ,
  learner,
  delta = 0.7,
  gamma = 1,
  iterations = 2,
  W_start = NULL,
  calc_dist = list(fun = calc_dist_default),
  calc_weight = list(fun = calc_weight_default, params = list(kernel = "gaussian"))
)

Arguments

data

(data.frame())
Data.frame containing the target variable, the covariates and a column with the corresponding individuals.

target

(character(1))
Name of the target variable.

individ

(character(1))
Name of the column with the individuals. Column has to be a factor.

learner

(LearnerRegr)
The machine learners from the mlr3-package.

delta

(numeric())
Parameter for the loss function

gamma

(gamma())
Parameter for the loss function

iterations

(integer(1))
Number of iterations.

W_start

(matrix())
Starting weights. Default is the identity matrix.

calc_dist

(function())
A list. If not set to default a list with the following components:

  • fun A function of the form function(model_1,model_2,task_list,...) to calculate the weights.

  • params A list of the additional parameters used in fun.

calc_weight

(function())
A list. If not set to default a list with the following components:

  • fun A function of the form function(dist, delta, gamma,...) to calculate the weights.

  • params A list of the additional parameters used in fun.


Method print()

Print ADS objects.

Usage

ADS$print()


Method fit()

Estimate ADS models.

Usage

ADS$fit(store_predictions = FALSE)

Arguments

store_predictions

(logical(1))
Indicates whether the predictions should be stored in field predictions_. Default is FALSE.

Returns

self


Method predict()

Predict ADS models on new data.

Usage

ADS$predict(newdata, iterations = NULL)

Arguments

newdata

(data.frame())
Predicts the model on new data. Has to be a data.frame with the same columns as in the trained model.

iterations

(vector())
Specifies the iterations to predict. Defaults to all iterations.

Returns

An array containing the predicted values over different iterations.


Method calc_mse()

Calculate the mean squared error for indiviuals over different iterations.

Usage

ADS$calc_mse(newdata)

Arguments

newdata

(data.frame())
Calculate the mean squared error on new data. Has to be a data.frame with the same columns as in the trained model.

Returns

A list containing the mean squared error for indiviudals and the combined model.


Method plot_mse()

Plot the mean squeared error over the iterations. At iteration zero, all predictions are initialized to be zero.

Usage

ADS$plot_mse(
  newdata = NULL,
  individuals = NULL,
  iterations = NULL,
  interactive = TRUE
)

Arguments

newdata

(data.frame())
Plot the mean squared error out-of-sample. Has to be a data.frame with the same columns as in the trained model.

individuals

(character())
Individuals to plot the weights for. Defaults to all individuals.

iterations

(integer())
Steps to plot the weights for. Defaults to all iterations.

interactive

(logical(1))
Create an interactive plot with plotly.

Returns

list


Method heatmap()

Plot the used weights as a heatmap.

Usage

ADS$heatmap(
  individuals = NULL,
  iterations = NULL,
  interactive = TRUE,
  show_axis_text = TRUE
)

Arguments

individuals

(character())
Individuals to plot the weights for. Defaults to all individuals.

iterations

(integer())
Steps to plot the weights for. Defaults to all iterations.

interactive

(logical(1))
Create an interactive plot with plotly.

show_axis_text

(logical(1))
Show axis tick text.

Returns

list


Method clone()

The objects of this class are cloneable with this method.

Usage

ADS$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.