eogrow.pipelines.prediction

Implements a base prediction pipeline and a LGBM specialized classification and regression pipelines.

class eogrow.pipelines.prediction.BasePredictionPipeline(config, raw_config=None)[source]

Bases: Pipeline

Pipeline to load a model and run prediction on EOPatches

Parameters:
  • config (Schema) – A dictionary with configuration parameters

  • raw_config (RawConfig | None) – The configuration parameters pre-validation, for logging purposes only

pydantic model Schema[source]

Bases: Schema

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Fields:
  • dtype (numpy.dtype | None)

  • input_features (List[Tuple[eolearn.core.constants.FeatureType, str]])

  • input_folder_key (str)

  • model_folder_key (str)

  • output_folder_key (str)

  • prediction_mask_feature_name (str | None)

  • prediction_mask_folder_key (str | None)

field dtype: np.dtype | None = None

Casts the result to desired type. Uses predictor output type by default.

Validated by:
  • optional_parse_dtype

field input_features: List[Feature] [Required]

List of features of form [(feature_type, feature_name)] specifying which features are model input in the correct order

field input_folder_key: str [Required]

The storage manager key pointing to the input folder of the model input data.

Validated by:
  • validate_storage_key

field model_folder_key: str [Required]

The storage manager key pointing to the folder of the model used in the prediction pipeline.

Validated by:
  • validate_storage_key

field output_folder_key: str [Required]

The storage manager key pointing to the output folder for the prediction pipeline.

Validated by:
  • validate_storage_key

field prediction_mask_feature_name: str | None = None

Name of MASK_TIMELESS feature which defines which areas will be predicted

field prediction_mask_folder_key: str | None = None
Validated by:
  • must_be_used_with_prediction_mask_feature_name

config: Schema
filter_patch_list(patch_list)[source]

EOPatches are filtered according to existence of specified output features

Parameters:

patch_list (List[Tuple[str, BBox]]) –

Return type:

List[Tuple[str, BBox]]

build_workflow()[source]

Workflow handling the prediction for eopatches. The workflow allows to add smoothing and custom thresholding to the predicted scores

Return type:

EOWorkflow

class eogrow.pipelines.prediction.RegressionPredictionPipeline(config, raw_config=None)[source]

Bases: BasePredictionPipeline

Parameters:
  • config (Schema) – A dictionary with configuration parameters

  • raw_config (RawConfig | None) – The configuration parameters pre-validation, for logging purposes only

pydantic model Schema[source]

Bases: Schema

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Fields:
  • clip_predictions (Optional[Tuple[float, float]])

  • model_filename (str)

  • output_feature_name (str)

field clip_predictions: Tuple[float, float] | None = None

Clip values of predictions to specified interval

field model_filename: str [Required]

A filename of a regression model to be used for prediction.

field output_feature_name: str [Required]
config: Schema
class eogrow.pipelines.prediction.ClassificationPredictionPipeline(config, raw_config=None)[source]

Bases: BasePredictionPipeline

Parameters:
  • config (Schema) – A dictionary with configuration parameters

  • raw_config (RawConfig | None) – The configuration parameters pre-validation, for logging purposes only

pydantic model Schema[source]

Bases: Schema

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Fields:
  • label_encoder_filename (Optional[str])

  • model_filename (str)

  • output_feature_name (str)

  • output_probability_feature_name (Optional[str])

field label_encoder_filename: str | None = None

Whether the predictions need to be decoded. The label encoder should be in the same model folder.

field model_filename: str [Required]

A filename of a classification model to be used for prediction.

field output_feature_name: str [Required]
field output_probability_feature_name: str | None = None
config: Schema