Skip to contents

Computes a selection of external evaluation metrics for partition.

Usage

getPartitionMetrics(
  true,
  pred,
  metrics = c("WC", "WH", "AWC", "AWH", "FM"),
  level = "class",
  ...
)

Arguments

true

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

pred

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. If omitted, main metrics will be computed. See details.

level

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

...

Optional arguments for MI, VI, or VM. See clevr::mutual_info(), clevr::variation_info() and clevr::v_measure() for more 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:

    • "SPC": Spot-wise Pair Concordance.

    • "ASPC": Adjusted Spot-wise Pair Concordance.

  • If level = "class", the allowed metrics are: "WC","WH","AWC","AWH","FM" (see below for details).

  • If level = "dataset", the allowed metrics are:

    • "RI": Rand Index

    • "WC": Wallace Completeness

    • "WH": Wallace Homogeneity

    • "ARI": Adjusted Rand Index

    • "AWC": Adjusted Wallace Completeness

    • "AWH": Adjusted Wallace Homogeneity

    • "NCR": Normalized class size Rand index

    • "MI": Mutual Information

    • "AMI": Adjusted Mutual Information

    • "VI": Variation of Information

    • "EH": (Entropy-based) Homogeneity

    • "EC": (Entropy-based) Completeness

    • "VM": V-measure

    • "FM": F-measure/weighted average F1 score

    • "VDM": Van Dongen Measure

    • "MHM": Meila-Heckerman Measure

    • "MMM": Maximum-Match Measure

    • "Mirkin": Mirkin Metric

    • "Accuracy": Set Matching Accuracy

Examples

true <- rep(LETTERS[1:3], each=10)
pred <- c(rep("A", 8), rep("B", 9), rep("C", 3), rep("D", 10))
getPartitionMetrics(true, pred, level="class")
#>          WC       AWC        FM class        WH       AWH cluster
#> 1 0.6444444 0.5211558 0.8888889     A        NA        NA    <NA>
#> 2 0.5333333 0.3715170 0.7368421     B        NA        NA    <NA>
#> 3 1.0000000 1.0000000 1.0000000     C        NA        NA    <NA>
#> 4        NA        NA        NA  <NA> 1.0000000 1.0000000       A
#> 5        NA        NA        NA  <NA> 0.6111111 0.4361111       B
#> 6        NA        NA        NA  <NA> 1.0000000 1.0000000       C
#> 7        NA        NA        NA  <NA> 1.0000000 1.0000000       D
getPartitionMetrics(true, pred, level="dataset")
#>          WC    WH      AWC     AWH        FM
#> 1 0.7259259 0.875 0.630891 0.81875 0.8752437