SL - Basics
Ver. 0.5.1 (2023-06-24)
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_metrics: ~typing.List[~mlpro.sl.models_eval.Metric] = [], p_score_metric=None, p_name: str = 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 = '????'
- _setup_model()
A method to set up a supervised learning network. Please redefine this method according to the type of network, if not provided yet.
- Return type:
A set up supervised learning model
- get_input_space()
- get_output_space()
- get_logging_data() list
- get_model()
A method to get the supervised learning network.
- Return type:
A set up supervised learning model
- adapt(p_input: Element = None, p_output: Element = None, p_dataset=None) bool
Adaption by supervised learning.
- _adapt(p_input: Element, p_output: Element, p_dataset: Buffer) bool
Adaptation algorithm that is called by public adaptation method. This covers online and offline supervised learning. Online learning means that the data set is dynamic according to the input data, meanwhile offline learning means that the learning procedure is based on a static data set.
- _adapt_online(p_input: Element, p_output: Element) bool
Custom adaptation algorithm for online learning. Please redefine.
- _adapt_offline(p_dataset: Buffer) bool
Custom adaptation algorithm for offline learning. Please redefine.
- Parameters:
p_dataset (Buffer) – A set of data for offline learning
- Return type:
bool
- 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.
- get_metrics() list
- get_score_metric()
- get_current_metrics()