Evaluation and validation#

Evaluation, validation and benchmarking.

Segmentation and clustering metrics, retrieval curves, stability, sensitivity, statistical tests and benchmarks.

Classes#

Benchmark(methods, datasets[, task, metrics])

Systematic comparison of methods on data sets.

Functions#

change_point_scores(true, pred[, margin, ...])

Precision, recall and F1 of change points with a tolerance margin.

f1_score_cp(true, pred[, margin])

F1 of change points (see change_point_scores()).

covering(true, pred[, n_samples])

Covering of the true segmentation by the predicted one: \(C(G,G')=\frac1T\sum_{A\in G}\lvert A\rvert\max_{A'\in G'}J(A,A')\) with the Jaccard index \(J\) of the segments (1 = identical).

hausdorff(true, pred)

Hausdorff distance of the two change point sets (inf if exactly one is empty).

annotation_error(true, pred)

Absolute difference of the numbers of change points.

mean_boundary_error(true, pred)

Mean distance of every true change point to the nearest predicted one.

state_scores(true_labels, pred_labels)

Adjusted Rand index, adjusted mutual information and normalized mutual information of per-sample state (or segment) labels.

evaluate_segmentation(true, pred[, ...])

All segmentation scores at once.

purity(true, pred)

Fraction of objects in the majority class of their cluster.

matched_accuracy(true, pred)

Accuracy after the optimal one-to-one matching of clusters and classes (Hungarian algorithm).

clustering_scores(true, pred)

ARI, AMI, NMI, purity and matched accuracy.

silhouette(D, labels)

Mean silhouette width from a distance matrix (noise label -1 ignored).

dunn_index(D, labels)

Smallest between-cluster distance divided by the largest cluster diameter.

partition_coefficient(U)

Bezdek's partition coefficient of a membership matrix (N, c).

partition_entropy(U)

Bezdek's partition entropy of a membership matrix (N, c).

knn_accuracy(D, labels[, k])

Leave-one-out k-NN classification accuracy from a distance matrix (1 - the 1-NN error rate of the UCR experiments).

precision_recall_curve_knn(D, labels[, r_items])

Precision at recall levels r = 1..r_items (Bankó, 2015, Alg.

mean_average_precision(D, labels)

Mean average precision of leave-one-out retrieval.

segmentation_stability(segmenter, X[, ...])

Stability of a segmentation under perturbations.

clustering_stability(clusterer, data[, ...])

Mean pairwise ARI of clusterings of random subsamples, compared on the objects they share.

sensitivity(factory, param, values, X[, score])

Run factory(**{param: v}) for every value and record the number of segments, the change points and an optional score(segmentation).

friedman_nemenyi(scores[, higher_is_better, ...])

Friedman test and Nemenyi critical difference.

wilcoxon_holm(scores[, alpha])

Pairwise Wilcoxon signed-rank tests with Holm's correction; returns a pandas DataFrame (method_a, method_b, p_value, p_holm, significant).

grid_search_segmenter(factory, grid, data[, ...])

Grid search of segmenter parameters.