Learn R Programming

stream (version 1.5-1)

EvalCallback-class: Abstract Class for Evaluation Callbacks

Description

The abstract class for all evaluation callbacks. Cannot be instantiated. Must be inherited. Evaluation is the process of the clustering quality assessment. This assessment can include clustering results, as well as the clustering process, e.g., duration, spatial query performance, and similar. The stream package has some measurements (see evaluate for details) already implemented. All other measurements can be externally implemented without need to extend the stream package, by using callbacks.

Usage

EvalCallback(...)

Arguments

...

further arguments.

Fields

all_measures

A list of all measures this object contributes to the evaluation. Union of all callback measures defines measures the end-user can use.

internal_measures

A list of internal measures. A subset of all_measures.

external_measures

A list of external measures. A subset of all_measures.

outlier_measures

A list of outlier measures. A subset of all_measures.

Author

Dalibor Krleža

Examples

Run this code

CustomCallback <- function() {
  env <- environment()
  all_measures <- c("LowestWeightPercentage")
  internal_measures <- c()
  external_measures <- all_measures
  outlier_measures <- c()
  this <- list(description = "Custom evaluation callback",
               env = environment())
  class(this) <- c("CustomCallback", "EvalCallback")
  this
}
evaluate_callback.CustomCallback <- function(cb_obj, dsc, measure, points,
                                             actual, predict, outliers,
                                             predict_outliers,
                                             predict_outliers_corrid,
                                             centers, noise) {
    r <- list()
    if("LowestWeightPercentage" %in% measure)
        r$LowestWeightPercentage=min(get_weights(dsc))/sum(get_weights(dsc))
    r
}
stream <- DSD_Gaussians(k = 3, d = 2, p = c(0.2, 0.4, 0.4))
km <- DSC_Kmeans(3)
update(km, stream, n=500)
evaluate_with_callbacks(km, stream, type="macro", n=500,
                        measure = c("crand","LowestWeightPercentage"),
                        callbacks = list(cc=CustomCallback()))

Run the code above in your browser using DataLab