Skip to contents

This object wraps the predictions returned by a learner of class LearnerClust, i.e. the predicted partition and cluster probability.

Super class

mlr3::Prediction -> PredictionClust

Active bindings

partition

(integer())
Access the stored partition.

prob

(matrix())
Access to the stored probabilities.

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage

PredictionClust$new(
  task = NULL,
  row_ids = task$row_ids,
  partition = NULL,
  prob = NULL,
  check = TRUE
)

Arguments

task

(TaskClust)
Task, used to extract defaults for row_ids.

row_ids

(integer())
Row ids of the predicted observations, i.e. the row ids of the test set.

partition

(integer())
Vector of cluster partitions.

prob

(matrix())
Numeric matrix of cluster membership probabilities with one column for each cluster and one row for each observation. Columns must be named with cluster numbers, row names are automatically removed. If prob is provided, but partition is not, the cluster memberships are calculated from the probabilities using max.col() with ties.method set to "first".

check

(logical(1))
If TRUE, performs some argument checks and predict type conversions.


Method clone()

The objects of this class are cloneable with this method.

Usage

PredictionClust$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

library(mlr3)
library(mlr3cluster)
task = tsk("usarrests")
learner = lrn("clust.kmeans")
p = learner$train(task)$predict(task)
p$predict_types
#> [1] "partition"
head(as.data.table(p))
#>    row_ids partition
#>      <int>     <int>
#> 1:       1         2
#> 2:       2         2
#> 3:       3         2
#> 4:       4         2
#> 5:       5         2
#> 6:       6         2