eolearn.ml_tools.truth_transformations

Module for transforming reference labels

class eolearn.ml_tools.truth_transformations.Mask2Label(mode, target_value=1, target_threshold=0.5)[source]

Bases: object

Transforms mask (shape n x m) into a single label.

Transformation works in two modes:

  • majority: assign label to the class with the largest contribution

  • target: assign label to target if its contribution percentage is above or equal to target threshold. In other cases label is set to 0.

The parameters target_value and target_threshold are taken into account only in target mode.

Parameters
  • mode (str) – A conversion mode, options are ‘majority’ or ‘target’

  • target_value (int) – A target value

  • target_threshold (float) – Fraction of pixels in mask that need to belong to the target to be labeled as target

transform(X)[source]
Parameters

X (np.ndarray) – An array in form of (n, m)

class eolearn.ml_tools.truth_transformations.Mask2TwoClass(positive_class_definition)[source]

Bases: object

The masks can include non-exclusive-multi-class labels described with bit pattern. This transformer simplifies the mask in form of bit-pattern to two class labels.

Parameters

positive_class_definition (int or string) – A bit pattern, (e.g. ‘100001’) defining the positive class if argument is an int then the mask is not interpreted as bit pattern

transform(X)[source]
Parameters

X (np.ndarray) – An array in form of (n, m)