Skip to contents

Computes embedding-based metrics for the specified level.

Usage

getEmbeddingMetrics(
  x,
  labels,
  metrics = c("meanSW", "minSW", "pnSW", "dbcv"),
  distance = "euclidean",
  level = "class",
  ...
)

Arguments

x

A data.frame or matrix (with features as columns and items as rows) from which the metrics will be computed.

labels

A vector containing the labels of the predicted clusters. Must be a vector of characters, integers, numerics, or a factor, but not a list.

metrics

The metrics to compute. See details.

distance

The distance metric to use (default euclidean).

level

The level to calculate the metrics. Options include "element", "class" and "dataset".

...

Optional arguments. See details.

Value

A data.frame of metrics.

Details

The allowed values for metrics depend on the value of level:

  • If level = "element", the allowed metrics are: "SW".

  • If level = "class", the allowed metrics are: "meanSW", "minSW", "pnSW", "dbcv".

  • If level = "dataset", the allowed metrics are: "meanSW", "meanClassSW", "pnSW", "minClassSW", "cdbw", "cohesion", "compactness", "sep", "dbcv".

The function(s) that the optional arguments ... passed to depend on the value of level:

  • If level = "element", optional arguments are passed to stats::dist().

  • If level = "class", optional arguments are passed to dbcv().

  • If level = "dataset", optional arguments are passed to dbcv() or CDbw().

Examples

d1 <- mockData()
getEmbeddingMetrics(d1[,1:2], labels=d1$class, 
metrics=c("meanSW", "minSW", "pnSW", "dbcv"), level="class")
#>   class    meanSW      minSW pnSW       dbcv
#> 1     A 0.2398886 -0.3123599 0.12 -0.5434214
#> 2     B 0.1255021 -0.4781851 0.20 -0.6382858