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