eolearn.ml_tools.validator

Module for validating results obtained from any ML classifier

class eolearn.ml_tools.validator.SGMLBaseValidator(class_dictionary)[source]

Bases: abc.ABC

Abstract class for various validations of SGML image classifiers.

All the work is performed in the validate method, where for each EOPatch the following actions are performed:

    1. execute WOWorkflow on EOPatch

    1. extract ground truth (reference) from the EOPatch

    • sets self.truth_masks

    • the class values in ground truth has to the same as in the provided dictionary

    1. count truth labeled pixels

    • sets self.pixel_truth_counts

    1. extract classification from the EOPatch

    • sets self.classification_masks

    1. count classified pixels

    • sets self.pixel_classification_counts

    1. collect results

    • sets pixel_truth_sum and pixel_classification_sum

Parameters

class_dictionary (dict) – Dictionary of class names and class values

reset_counters()[source]

Resets all counters, truth and classification masks.

add_validation_patch(patch)[source]

Extracts ground truth and classification results from the EOPatch and aggregates the results.

validate()[source]

Aggregate the results from all EOPatches.

save(filename)[source]

Save validator object to pickle.

pandas_df()[source]

Returns pandas DataFrame containing pixel counts for all truth classes, classified classes (for each truth class), and file name of the input EODataSet.

The data frame thus contains

N = self.n_validation_sets rows

and

M = len(self.truth_classes) + len(self.truth_classes) * len (self.class_dictionary) + 1 columns

to_csv(filename)[source]

Writes validation results using pandas to csv file.

confusion_matrix()[source]

Returns the normalised confusion matrix

plot_confusion_matrix(normalised=True)[source]

Plots the confusion matrix.

summary(scoring)[source]

Prints out the summary of validation for giving scoring function.