Preprocessing
Ver. 2.3.0 (2025-06-25)
This module provides a basic implementation of a boundary detector.
- class mlpro.oa.streams.tasks.boundarydetectors.basic.BoundaryDetector(p_name: str = None, p_range_max=1, p_ada: bool = True, p_duplicate_data: bool = False, p_visualize: bool = False, p_logging=True, p_boundary_provider: BoundaryProvider = None, **p_kwargs)
Bases:
OAStreamTask,BoundaryProviderThis class provides the functionality of boundary observation of incoming instances.
- Parameters:
p_name (str, Optional.) – Name of the task.
p_range_max – Processing range of the task. Default is thread.
p_ada (bool) – True if the task has adaptivity. Default is True.
p_duplicate_data (bool) – If True, instances will be duplicated before processing. Default = False.
p_visualize (bool) – True to turn on the visualization.
p_logging – Logging level for the task, default is Log all.
p_boundary_provider (BoundaryProvider = None) – Optional boundary provider, used for service call on reverse adaptation.
- C_TYPE = 'Boundary Detector'
- C_PLOT_ND_XLABEL = 'Features'
- C_PLOT_ND_YLABEL = 'Boundaries'
- C_PLOT_STANDALONE: bool = True
- C_PLOT_VALID_VIEWS: list = ['ND']
- C_PLOT_DEFAULT_VIEW: str = 'ND'
- _run(p_instances: Dict[int, Tuple[str, Instance]])
Method to run the boundary detector task
- Parameters:
p_instances (InstDict) – Instances to be processed.
- adapt(p_instances: Dict[int, Tuple[str, Instance]]) bool
Adapts the model by calling the custom method _adapt().
- Parameters:
**p_kwargs – All parameters that are needed for the adaption. Depends on the specific higher context.
- Returns:
adapted – True, if something has been adapted. False otherwise.
- Return type:
bool
- _adapt(p_instance_new: Instance) bool
Extends boundaries based on a new instance.
- Parameters:
p_instance_new (Instance) – New instance to be processed.
- Returns:
True, if at least one boundary value has been extended. False otherwise.
- Return type:
bool
- _adapt_reverse(p_instance_del: Instance) bool
Determines the boundaries to be reduced based on an outdated instance.
- Parameters:
p_instance_del (Instance) – Deleted instance to be processed.
- Returns:
True, if at least one boundary value needs to be reduced. False otherwise.
- Return type:
bool
- _adapt_post() OAStreamAdaptationType
…
- get_boundaries(p_dim: int = None, p_side: BoundarySide = None) ndarray[tuple[Any, ...], dtype[float64]] | float
Returns the current value boundaries of internally stored data. The result can be reduced by the optional parameters p_side, p_dim. If both parameters are specified, the result is a float.
- Parameters:
p_dim (int = None) – Optionally reduces the result to a particular dimension.
p_side (BoundarySide = None) – Optionally reduces the result to upper or lower boundaries. See class BoundarySide for possible values.
- Returns:
Returns the current boundaries of the data. The return value depends on the combination of the optional parameters: - If neither p_side nor p_dim is specified: returns the full 2×n array. - If only p_side is specified: returns a 1D array with values for all dimensions. - If only p_dim is specified: returns a 1D array with both lower and upper bounds. - If both p_side and p_dim are specified: returns a single float value.
- Return type:
Union[Boundaries, float]
- _init_plot_nd(p_figure: Figure, p_settings: PlotSettings)
Custom method to initialize plot for Boundary Detectors tasks for N-dimensional plotting.
- Parameters:
p_figure (Figure) – Figure to host the plot
p_settings (PlotSettings) – PlotSettings objects with specific settings for the plot
- _update_plot_nd(p_settings: PlotSettings, p_instances: Dict[int, Tuple[str, Instance]], **p_kwargs) bool
N-dimensional plotting for Boundary Detector using vertical bars and mean markers.
- Parameters:
p_settings (PlotSettings) – Plot settings object including matplotlib axes.
p_instances (InstDict) – Optional stream instances (not used here).
p_kwargs (dict) – Further optional parameters.
- Returns:
True, if changes on the plot require a refresh of the figure. False otherwise.
- Return type:
bool
Ver. 2.0.0 (2025-06-30)
This module provides implementation for adaptive normalizers for MinMax Normalization.
- class mlpro.oa.streams.tasks.normalizers.minmax.NormalizerMinMax(p_name: str = None, p_range_max=1, p_ada: bool = True, p_duplicate_data: bool = False, p_visualize: bool = False, p_logging=True, p_dst_boundaries: list = [-1, 1], **p_kwargs)
Bases:
NormalizerMinMax,OAStreamNormalizerClass with functionality for adaptive normalization of instances using MinMax Normalization.
- Parameters:
p_name (str = None,) – Optional name of the task.
p_range_max – Processing range of the task, default is a Thread.
p_ada (bool) – True if the task has adaptivity, default is true.
p_duplicate_data (bool) – If True, instances will be duplicated before processing. Default = False.
p_visualize – True for visualization, false by default.
p_logging – Logging level of the task. Default is Log.C_LOG_ALL
p_dst_boundaries (list = [-1,1]) – Explicit list of (low, high) destination boundaries. Default is [-1, 1].
**p_kwargs – Additional task parameters
- C_NAME = 'MinMax'
- _run(p_instances: Dict[int, Tuple[str, Instance]])
Runs MinMax Normalizer task for normalizing stream instances.
- Parameters:
p_instances (InstDict) – Instances to be processed
- _adapt_on_event(p_event_id: str, p_event_object: Event) bool
Custom method to adapt the MinMax normalizer parameters based on event raised by Boundary object for changed boundaries.
- Parameters:
p_event_id (str) – Event id of the raised event
p_event_obj (Event) – Event object that raises the corresponding event
- Returns:
Returns True, if the task has adapted. False otherwise.
- Return type:
bool
- _update_plot_data_2d()
Updates the 2D plot data after parameter changes by renormalizing the existing points.
- _update_plot_data_3d()
Method to update the 3d plot for Normalizer. Extended to renormalize the obsolete data on change of parameters.
- _update_plot_data_nd()
Method to update the nd plot for Normalizer. Extended to renormalize the obsolete data on change of parameters.
Ver. 2.1.0 (2025-07-05)
This module provides implementation for adaptive normalizers for ZTransformation
- class mlpro.oa.streams.tasks.normalizers.ztrans.NormalizerZTransform(p_name: str = None, p_range_max=1, p_ada: bool = True, p_duplicate_data: bool = False, p_visualize=False, p_logging=True, **p_kwargs)
Bases:
NormalizerZTrans,OAStreamNormalizerOnline-adaptive normalization of instances with Z-transformation.
- Parameters:
p_name (str, optional) – Name of the task.
p_range_max – Processing range of the task, default is a Thread.
p_ada – True if the task has adaptivity, default is true.
p_duplicate_data (bool) – If True, instances will be duplicated before processing. Default = False.
p_visualize – True for visualization, false by default.
p_logging – Logging level of the task. Default is Log.C_LOG_ALL
**p_kwargs – Additional task parameters
- C_NAME = 'ZTrans'
- _run(p_instances: Dict[int, Tuple[str, Instance]])
Custom method to for run Z-transform task for normalizing new instances and denormalizing deleted instances.
- Parameters:
p_instances (InstDict) – Stream instances to be processed
- _adapt(p_instance_new: Instance) bool
Custom method to for adapting of Z-transform parameters on new instances.
- Parameters:
p_instance_new (Instance) – Instance to be adapted on.
- Returns:
adapted – Returns True, if task has adapted.
- Return type:
bool
- _adapt_reverse(p_instance_del: Instance) bool
Custom method to for adapting of Z-transform parameters on deleted instances.
- Parameters:
p_instance_del (Instance) – Instance to be adapted on.
- Returns:
adapted – Returns True, if task has adapted.
- Return type:
bool
- _update_plot_data_2d()
Updates the 2D plot data after parameter changes by renormalizing the existing points.
- _update_plot_data_3d()
Method to update the 3d plot for Normalizer. Extended to renormalize the obsolete data on change of parameters.
- _update_plot_data_nd()
Method to update the nd plot for Normalizer. Extended to renormalize the obsolete data on change of parameters.
- _update_plot_data()
Updates the plot data.