SL - Basics

content/04_appendices/appendix2/sub/core/mlpro_sl/images/MLPro-SL-basics_class_diagram.drawio.png

Ver. 0.4.3 (2023-03-10)

This module provides model classes for supervised learning tasks.

class mlpro.sl.basics.SLAdaptiveFunction(p_input_space: ~mlpro.bf.math.basics.MSpace, p_output_space: ~mlpro.bf.math.basics.MSpace, p_output_elem_cls=<class 'mlpro.bf.math.basics.Element'>, p_threshold=0, p_ada: bool = True, p_buffer_size: int = 0, p_name: str | None = None, p_range_max: int = 2, p_autorun=0, p_class_shared=None, p_visualize: bool = False, p_logging=True, **p_par)

Bases: AdaptiveFunction

Template class for an adaptive bi-multivariate mathematical function that adapts by supervised learning.

Parameters:
  • p_input_space (MSpace) – Input space of function

  • p_output_space (MSpace) – Output space of function

  • p_output_elem_cls – Output element class (compatible to/inherited from class Element)

  • p_threshold (float) – Threshold for the difference between a setpoint and a computed output. Computed outputs with a difference less than this threshold will be assessed as ‘good’ outputs. Default = 0.

  • p_ada (bool) – Boolean switch for adaptivitiy. Default = True.

  • p_buffer_size (int) – Initial size of internal data buffer. Defaut = 0 (no buffering).

  • p_name (str) – Optional name of the model. Default is None.

  • p_range_max (int) – Maximum range of asynchonicity. See class Range. Default is Range.C_RANGE_PROCESS.

  • p_autorun (int) – On value C_AUTORUN_RUN method run() is called imediately during instantiation. On vaule C_AUTORUN_LOOP method run_loop() is called. Value C_AUTORUN_NONE (default) causes an object instantiation without starting further actions.

  • p_class_shared – Optional class for a shared object (class Shared or a child class of it)

  • p_visualize (bool) – Boolean switch for visualisation. Default = False.

  • p_logging – Log level (see constants of class Log). Default: Log.C_LOG_ALL

  • p_par (Dict) – Further model specific hyperparameters (to be defined in chhild class).

C_TYPE = 'Adaptive Function (SL)'
C_NAME = '????'
get_model()

A method to get the supervised learning network.

Return type:

A set up supervised learning model

adapt(p_input: Element | None = None, p_output: Element | None = None, p_dataset=None) bool

Adaption by supervised learning.

Parameters:
  • p_input (Element) – Abscissa/input element object (type Element)

  • p_output (Element) – Setpoint ordinate/output element (type Element)

  • p_dataset – A set of data for offline learning

get_accuracy()

Returns the accuracy of the adaptive function. The accuracy is defined as the relation between the number of successful mapped inputs and the total number of mappings since the last adaptation.

class mlpro.sl.basics.SLScenario(p_mode=0, p_ada: bool = True, p_cycle_limit: int = 0, p_visualize: bool = True, _logging=True)

Bases: Scenario

To be designed.

C_TYPE = 'SL-Scenario'
class mlpro.sl.basics.SLTraining(**p_kwargs)

Bases: Training

To be designed.

C_NAME = 'SL'