# gaitsetpy.core.managers

Singleton managers for GaitSetPy components.

This module provides singleton managers for each component type that handle plugin registration, discovery, and instantiation.

Maintainer: @aharshit123456

View Source

      1"""
      2Singleton managers for GaitSetPy components.
      3
      4This module provides singleton managers for each component type that handle
      5plugin registration, discovery, and instantiation.
      6
      7Maintainer: @aharshit123456
      8"""
      9
     10import threading
     11from typing import Dict, List, Type, Any, Optional, Union
     12from .base_classes import (
     13    BaseDatasetLoader,
     14    BaseFeatureExtractor,
     15    BasePreprocessor,
     16    BaseEDAAnalyzer,
     17    BaseClassificationModel
     18)
     19
     20
     21class SingletonMeta(type):
     22    """
     23    Metaclass for implementing singleton pattern with thread safety.
     24    """
     25    _instances = {}
     26    _lock = threading.Lock()
     27
     28    def __call__(cls, *args, **kwargs):
     29        with cls._lock:
     30            if cls not in cls._instances:
     31                cls._instances[cls] = super().__call__(*args, **kwargs)
     32            return cls._instances[cls]
     33
     34
     35class BaseManager(metaclass=SingletonMeta):
     36    """
     37    Base manager class for all component managers.
     38    """
     39
     40    def __init__(self):
     41        self._registry: Dict[str, Type] = {}
     42        self._instances: Dict[str, Any] = {}
     43        self._lock = threading.Lock()
     44
     45    def register(self, name: str, component_class: Type):
     46        """
     47        Register a component class.
     48
     49        Args:
     50            name: Name to register the component under
     51            component_class: Component class to register
     52        """
     53        with self._lock:
     54            self._registry[name] = component_class
     55
     56    def unregister(self, name: str):
     57        """
     58        Unregister a component.
     59
     60        Args:
     61            name: Name of the component to unregister
     62        """
     63        with self._lock:
     64            if name in self._registry:
     65                del self._registry[name]
     66            if name in self._instances:
     67                del self._instances[name]
     68
     69    def get_available_components(self) -> List[str]:
     70        """
     71        Get list of available component names.
     72
     73        Returns:
     74            List of registered component names
     75        """
     76        return list(self._registry.keys())
     77
     78    def get_component_info(self, name: str) -> Optional[Dict[str, Any]]:
     79        """
     80        Get information about a registered component.
     81
     82        Args:
     83            name: Name of the component
     84
     85        Returns:
     86            Component information dictionary or None if not found
     87        """
     88        if name in self._registry:
     89            component_class = self._registry[name]
     90            return {
     91                'name': name,
     92                'class': component_class.__name__,
     93                'module': component_class.__module__,
     94                'doc': component_class.__doc__
     95            }
     96        return None
     97
     98    def create_instance(self, name: str, *args, **kwargs) -> Any:
     99        """
    100        Create an instance of a registered component.
    101
    102        Args:
    103            name: Name of the component
    104            *args: Positional arguments for component constructor
    105            **kwargs: Keyword arguments for component constructor
    106
    107        Returns:
    108            Component instance
    109
    110        Raises:
    111            ValueError: If component is not registered
    112        """
    113        if name not in self._registry:
    114            raise ValueError(f"Component '{name}' is not registered")
    115
    116        component_class = self._registry[name]
    117        return component_class(*args, **kwargs)
    118
    119    def get_cached_instance(self, name: str, *args, **kwargs) -> Any:
    120        """
    121        Get a cached instance of a component, creating it if it doesn't exist.
    122
    123        Args:
    124            name: Name of the component
    125            *args: Positional arguments for component constructor
    126            **kwargs: Keyword arguments for component constructor
    127
    128        Returns:
    129            Component instance
    130        """
    131        with self._lock:
    132            if name not in self._instances:
    133                self._instances[name] = self.create_instance(name, *args, **kwargs)
    134            return self._instances[name]
    135
    136
    137class DatasetManager(BaseManager):
    138    """
    139    Singleton manager for dataset loaders.
    140    """
    141
    142    def register_dataset(self, name: str, dataset_class: Type[BaseDatasetLoader]):
    143        """
    144        Register a dataset loader.
    145
    146        Args:
    147            name: Name to register the dataset under
    148            dataset_class: Dataset loader class
    149        """
    150        if not issubclass(dataset_class, BaseDatasetLoader):
    151            raise ValueError(f"Dataset class must inherit from BaseDatasetLoader")
    152        self.register(name, dataset_class)
    153
    154    def load_dataset(self, name: str, data_dir: str, **kwargs) -> BaseDatasetLoader:
    155        """
    156        Load a dataset using the registered loader.
    157
    158        Args:
    159            name: Name of the dataset loader
    160            data_dir: Directory containing the dataset
    161            **kwargs: Additional arguments for the loader
    162
    163        Returns:
    164            Dataset loader instance with loaded data
    165        """
    166        loader = self.create_instance(name, name, f"{name} dataset loader")
    167        loader.load_data(data_dir, **kwargs)
    168        return loader
    169
    170
    171class FeatureManager(BaseManager):
    172    """
    173    Singleton manager for feature extractors.
    174    """
    175
    176    def register_extractor(self, name: str, extractor_class: Type[BaseFeatureExtractor]):
    177        """
    178        Register a feature extractor.
    179
    180        Args:
    181            name: Name to register the extractor under
    182            extractor_class: Feature extractor class
    183        """
    184        if not issubclass(extractor_class, BaseFeatureExtractor):
    185            raise ValueError(f"Extractor class must inherit from BaseFeatureExtractor")
    186        self.register(name, extractor_class)
    187
    188    def extract_features(self, extractor_name: str, windows: List[Dict], fs: int, **kwargs) -> List[Dict]:
    189        """
    190        Extract features using the specified extractor.
    191
    192        Args:
    193            extractor_name: Name of the feature extractor
    194            windows: List of sliding window dictionaries
    195            fs: Sampling frequency
    196            **kwargs: Additional arguments for feature extraction
    197
    198        Returns:
    199            List of feature dictionaries
    200        """
    201        extractor = self.get_cached_instance(extractor_name, extractor_name, f"{extractor_name} feature extractor")
    202        return extractor.extract_features(windows, fs, **kwargs)
    203
    204
    205class PreprocessingManager(BaseManager):
    206    """
    207    Singleton manager for preprocessors.
    208    """
    209
    210    def register_preprocessor(self, name: str, preprocessor_class: Type[BasePreprocessor]):
    211        """
    212        Register a preprocessor.
    213
    214        Args:
    215            name: Name to register the preprocessor under
    216            preprocessor_class: Preprocessor class
    217        """
    218        if not issubclass(preprocessor_class, BasePreprocessor):
    219            raise ValueError(f"Preprocessor class must inherit from BasePreprocessor")
    220        self.register(name, preprocessor_class)
    221
    222    def preprocess_data(self, preprocessor_name: str, data: Any, **kwargs) -> Any:
    223        """
    224        Preprocess data using the specified preprocessor.
    225
    226        Args:
    227            preprocessor_name: Name of the preprocessor
    228            data: Input data to preprocess
    229            **kwargs: Additional arguments for preprocessing
    230
    231        Returns:
    232            Preprocessed data
    233        """
    234        preprocessor = self.get_cached_instance(preprocessor_name, preprocessor_name, f"{preprocessor_name} preprocessor")
    235        return preprocessor.fit_transform(data, **kwargs)
    236
    237
    238class EDAManager(BaseManager):
    239    """
    240    Singleton manager for EDA analyzers.
    241    """
    242
    243    def register_analyzer(self, name: str, analyzer_class: Type[BaseEDAAnalyzer]):
    244        """
    245        Register an EDA analyzer.
    246
    247        Args:
    248            name: Name to register the analyzer under
    249            analyzer_class: EDA analyzer class
    250        """
    251        if not issubclass(analyzer_class, BaseEDAAnalyzer):
    252            raise ValueError(f"Analyzer class must inherit from BaseEDAAnalyzer")
    253        self.register(name, analyzer_class)
    254
    255    def analyze_data(self, analyzer_name: str, data: Any, **kwargs) -> Dict[str, Any]:
    256        """
    257        Analyze data using the specified analyzer.
    258
    259        Args:
    260            analyzer_name: Name of the EDA analyzer
    261            data: Input data to analyze
    262            **kwargs: Additional arguments for analysis
    263
    264        Returns:
    265            Analysis results dictionary
    266        """
    267        analyzer = self.get_cached_instance(analyzer_name, analyzer_name, f"{analyzer_name} analyzer")
    268        return analyzer.analyze(data, **kwargs)
    269
    270    def visualize_data(self, analyzer_name: str, data: Any, **kwargs):
    271        """
    272        Create visualizations using the specified analyzer.
    273
    274        Args:
    275            analyzer_name: Name of the EDA analyzer
    276            data: Input data to visualize
    277            **kwargs: Additional arguments for visualization
    278        """
    279        analyzer = self.get_cached_instance(analyzer_name, analyzer_name, f"{analyzer_name} analyzer")
    280        analyzer.visualize(data, **kwargs)
    281
    282
    283class ClassificationManager(BaseManager):
    284    """
    285    Singleton manager for classification models.
    286    """
    287
    288    def register_model(self, name: str, model_class: Type[BaseClassificationModel]):
    289        """
    290        Register a classification model.
    291
    292        Args:
    293            name: Name to register the model under
    294            model_class: Classification model class
    295        """
    296        if not issubclass(model_class, BaseClassificationModel):
    297            raise ValueError(f"Model class must inherit from BaseClassificationModel")
    298        self.register(name, model_class)
    299
    300    def train_model(self, model_name: str, features: List[Dict], **kwargs) -> BaseClassificationModel:
    301        """
    302        Train a classification model.
    303
    304        Args:
    305            model_name: Name of the classification model
    306            features: List of feature dictionaries
    307            **kwargs: Additional arguments for training
    308
    309        Returns:
    310            Trained model instance
    311        """
    312        model = self.create_instance(model_name, model_name, f"{model_name} classification model")
    313        model.train(features, **kwargs)
    314        return model
    315
    316    def predict(self, model_name: str, features: List[Dict], **kwargs) -> Any:
    317        """
    318        Make predictions using a trained model.
    319
    320        Args:
    321            model_name: Name of the classification model
    322            features: List of feature dictionaries
    323            **kwargs: Additional arguments for prediction
    324
    325        Returns:
    326            Predictions array
    327        """
    328        model = self.get_cached_instance(model_name, model_name, f"{model_name} classification model")
    329        return model.predict(features, **kwargs)
    330
    331    def evaluate_model(self, model_name: str, features: List[Dict], **kwargs) -> Dict[str, float]:
    332        """
    333        Evaluate a classification model.
    334
    335        Args:
    336            model_name: Name of the classification model
    337            features: List of feature dictionaries
    338            **kwargs: Additional arguments for evaluation
    339
    340        Returns:
    341            Evaluation metrics dictionary
    342        """
    343        model = self.get_cached_instance(model_name, model_name, f"{model_name} classification model")
    344        return model.evaluate(features, **kwargs)

class SingletonMeta(builtins.type): View Source

    22class SingletonMeta(type):
    23    """
    24    Metaclass for implementing singleton pattern with thread safety.
    25    """
    26    _instances = {}
    27    _lock = threading.Lock()
    28
    29    def __call__(cls, *args, **kwargs):
    30        with cls._lock:
    31            if cls not in cls._instances:
    32                cls._instances[cls] = super().__call__(*args, **kwargs)
    33            return cls._instances[cls]

Metaclass for implementing singleton pattern with thread safety.

class BaseManager: View Source

     36class BaseManager(metaclass=SingletonMeta):
     37    """
     38    Base manager class for all component managers.
     39    """
     40
     41    def __init__(self):
     42        self._registry: Dict[str, Type] = {}
     43        self._instances: Dict[str, Any] = {}
     44        self._lock = threading.Lock()
     45
     46    def register(self, name: str, component_class: Type):
     47        """
     48        Register a component class.
     49
     50        Args:
     51            name: Name to register the component under
     52            component_class: Component class to register
     53        """
     54        with self._lock:
     55            self._registry[name] = component_class
     56
     57    def unregister(self, name: str):
     58        """
     59        Unregister a component.
     60
     61        Args:
     62            name: Name of the component to unregister
     63        """
     64        with self._lock:
     65            if name in self._registry:
     66                del self._registry[name]
     67            if name in self._instances:
     68                del self._instances[name]
     69
     70    def get_available_components(self) -> List[str]:
     71        """
     72        Get list of available component names.
     73
     74        Returns:
     75            List of registered component names
     76        """
     77        return list(self._registry.keys())
     78
     79    def get_component_info(self, name: str) -> Optional[Dict[str, Any]]:
     80        """
     81        Get information about a registered component.
     82
     83        Args:
     84            name: Name of the component
     85
     86        Returns:
     87            Component information dictionary or None if not found
     88        """
     89        if name in self._registry:
     90            component_class = self._registry[name]
     91            return {
     92                'name': name,
     93                'class': component_class.__name__,
     94                'module': component_class.__module__,
     95                'doc': component_class.__doc__
     96            }
     97        return None
     98
     99    def create_instance(self, name: str, *args, **kwargs) -> Any:
    100        """
    101        Create an instance of a registered component.
    102
    103        Args:
    104            name: Name of the component
    105            *args: Positional arguments for component constructor
    106            **kwargs: Keyword arguments for component constructor
    107
    108        Returns:
    109            Component instance
    110
    111        Raises:
    112            ValueError: If component is not registered
    113        """
    114        if name not in self._registry:
    115            raise ValueError(f"Component '{name}' is not registered")
    116
    117        component_class = self._registry[name]
    118        return component_class(*args, **kwargs)
    119
    120    def get_cached_instance(self, name: str, *args, **kwargs) -> Any:
    121        """
    122        Get a cached instance of a component, creating it if it doesn't exist.
    123
    124        Args:
    125            name: Name of the component
    126            *args: Positional arguments for component constructor
    127            **kwargs: Keyword arguments for component constructor
    128
    129        Returns:
    130            Component instance
    131        """
    132        with self._lock:
    133            if name not in self._instances:
    134                self._instances[name] = self.create_instance(name, *args, **kwargs)
    135            return self._instances[name]

Base manager class for all component managers.

def register(self, name: str, component_class: Type): View Source

    46    def register(self, name: str, component_class: Type):
    47        """
    48        Register a component class.
    49
    50        Args:
    51            name: Name to register the component under
    52            component_class: Component class to register
    53        """
    54        with self._lock:
    55            self._registry[name] = component_class

Register a component class.

Args: name: Name to register the component under component_class: Component class to register

def unregister(self, name: str): View Source

    57    def unregister(self, name: str):
    58        """
    59        Unregister a component.
    60
    61        Args:
    62            name: Name of the component to unregister
    63        """
    64        with self._lock:
    65            if name in self._registry:
    66                del self._registry[name]
    67            if name in self._instances:
    68                del self._instances[name]

Unregister a component.

Args: name: Name of the component to unregister

def get_available_components(self) -> List[str]: View Source

    70    def get_available_components(self) -> List[str]:
    71        """
    72        Get list of available component names.
    73
    74        Returns:
    75            List of registered component names
    76        """
    77        return list(self._registry.keys())

Get list of available component names.

Returns: List of registered component names

def get_component_info(self, name: str) -> Optional[Dict[str, Any]]: View Source

    79    def get_component_info(self, name: str) -> Optional[Dict[str, Any]]:
    80        """
    81        Get information about a registered component.
    82
    83        Args:
    84            name: Name of the component
    85
    86        Returns:
    87            Component information dictionary or None if not found
    88        """
    89        if name in self._registry:
    90            component_class = self._registry[name]
    91            return {
    92                'name': name,
    93                'class': component_class.__name__,
    94                'module': component_class.__module__,
    95                'doc': component_class.__doc__
    96            }
    97        return None

Get information about a registered component.

Args: name: Name of the component

Returns: Component information dictionary or None if not found

def create_instance(self, name: str, *args, **kwargs) -> Any: View Source

     99    def create_instance(self, name: str, *args, **kwargs) -> Any:
    100        """
    101        Create an instance of a registered component.
    102
    103        Args:
    104            name: Name of the component
    105            *args: Positional arguments for component constructor
    106            **kwargs: Keyword arguments for component constructor
    107
    108        Returns:
    109            Component instance
    110
    111        Raises:
    112            ValueError: If component is not registered
    113        """
    114        if name not in self._registry:
    115            raise ValueError(f"Component '{name}' is not registered")
    116
    117        component_class = self._registry[name]
    118        return component_class(*args, **kwargs)

Create an instance of a registered component.

Args: name: Name of the component args: Positional arguments for component constructor *kwargs: Keyword arguments for component constructor

Returns: Component instance

Raises: ValueError: If component is not registered

def get_cached_instance(self, name: str, *args, **kwargs) -> Any: View Source

    120    def get_cached_instance(self, name: str, *args, **kwargs) -> Any:
    121        """
    122        Get a cached instance of a component, creating it if it doesn't exist.
    123
    124        Args:
    125            name: Name of the component
    126            *args: Positional arguments for component constructor
    127            **kwargs: Keyword arguments for component constructor
    128
    129        Returns:
    130            Component instance
    131        """
    132        with self._lock:
    133            if name not in self._instances:
    134                self._instances[name] = self.create_instance(name, *args, **kwargs)
    135            return self._instances[name]

Get a cached instance of a component, creating it if it doesn't exist.

Args: name: Name of the component args: Positional arguments for component constructor *kwargs: Keyword arguments for component constructor

Returns: Component instance

class DatasetManager(BaseManager): View Source

    138class DatasetManager(BaseManager):
    139    """
    140    Singleton manager for dataset loaders.
    141    """
    142
    143    def register_dataset(self, name: str, dataset_class: Type[BaseDatasetLoader]):
    144        """
    145        Register a dataset loader.
    146
    147        Args:
    148            name: Name to register the dataset under
    149            dataset_class: Dataset loader class
    150        """
    151        if not issubclass(dataset_class, BaseDatasetLoader):
    152            raise ValueError(f"Dataset class must inherit from BaseDatasetLoader")
    153        self.register(name, dataset_class)
    154
    155    def load_dataset(self, name: str, data_dir: str, **kwargs) -> BaseDatasetLoader:
    156        """
    157        Load a dataset using the registered loader.
    158
    159        Args:
    160            name: Name of the dataset loader
    161            data_dir: Directory containing the dataset
    162            **kwargs: Additional arguments for the loader
    163
    164        Returns:
    165            Dataset loader instance with loaded data
    166        """
    167        loader = self.create_instance(name, name, f"{name} dataset loader")
    168        loader.load_data(data_dir, **kwargs)
    169        return loader

Singleton manager for dataset loaders.

def register_dataset( self, name: str, dataset_class: Type[gaitsetpy.BaseDatasetLoader]): View Source

    143    def register_dataset(self, name: str, dataset_class: Type[BaseDatasetLoader]):
    144        """
    145        Register a dataset loader.
    146
    147        Args:
    148            name: Name to register the dataset under
    149            dataset_class: Dataset loader class
    150        """
    151        if not issubclass(dataset_class, BaseDatasetLoader):
    152            raise ValueError(f"Dataset class must inherit from BaseDatasetLoader")
    153        self.register(name, dataset_class)

Register a dataset loader.

Args: name: Name to register the dataset under dataset_class: Dataset loader class

def load_dataset( self, name: str, data_dir: str, **kwargs) -> gaitsetpy.BaseDatasetLoader: View Source

    155    def load_dataset(self, name: str, data_dir: str, **kwargs) -> BaseDatasetLoader:
    156        """
    157        Load a dataset using the registered loader.
    158
    159        Args:
    160            name: Name of the dataset loader
    161            data_dir: Directory containing the dataset
    162            **kwargs: Additional arguments for the loader
    163
    164        Returns:
    165            Dataset loader instance with loaded data
    166        """
    167        loader = self.create_instance(name, name, f"{name} dataset loader")
    168        loader.load_data(data_dir, **kwargs)
    169        return loader

Load a dataset using the registered loader.

Args: name: Name of the dataset loader data_dir: Directory containing the dataset **kwargs: Additional arguments for the loader

Returns: Dataset loader instance with loaded data

##### Inherited Members

BaseManager
  register
  unregister
  get_available_components
  get_component_info
  create_instance
  get_cached_instance

class FeatureManager(BaseManager): View Source

    172class FeatureManager(BaseManager):
    173    """
    174    Singleton manager for feature extractors.
    175    """
    176
    177    def register_extractor(self, name: str, extractor_class: Type[BaseFeatureExtractor]):
    178        """
    179        Register a feature extractor.
    180
    181        Args:
    182            name: Name to register the extractor under
    183            extractor_class: Feature extractor class
    184        """
    185        if not issubclass(extractor_class, BaseFeatureExtractor):
    186            raise ValueError(f"Extractor class must inherit from BaseFeatureExtractor")
    187        self.register(name, extractor_class)
    188
    189    def extract_features(self, extractor_name: str, windows: List[Dict], fs: int, **kwargs) -> List[Dict]:
    190        """
    191        Extract features using the specified extractor.
    192
    193        Args:
    194            extractor_name: Name of the feature extractor
    195            windows: List of sliding window dictionaries
    196            fs: Sampling frequency
    197            **kwargs: Additional arguments for feature extraction
    198
    199        Returns:
    200            List of feature dictionaries
    201        """
    202        extractor = self.get_cached_instance(extractor_name, extractor_name, f"{extractor_name} feature extractor")
    203        return extractor.extract_features(windows, fs, **kwargs)

Singleton manager for feature extractors.

def register_extractor( self, name: str, extractor_class: Type[gaitsetpy.BaseFeatureExtractor]): View Source

    177    def register_extractor(self, name: str, extractor_class: Type[BaseFeatureExtractor]):
    178        """
    179        Register a feature extractor.
    180
    181        Args:
    182            name: Name to register the extractor under
    183            extractor_class: Feature extractor class
    184        """
    185        if not issubclass(extractor_class, BaseFeatureExtractor):
    186            raise ValueError(f"Extractor class must inherit from BaseFeatureExtractor")
    187        self.register(name, extractor_class)

Register a feature extractor.

Args: name: Name to register the extractor under extractor_class: Feature extractor class

def extract_features( self, extractor_name: str, windows: List[Dict], fs: int, **kwargs) -> List[Dict]: View Source

    189    def extract_features(self, extractor_name: str, windows: List[Dict], fs: int, **kwargs) -> List[Dict]:
    190        """
    191        Extract features using the specified extractor.
    192
    193        Args:
    194            extractor_name: Name of the feature extractor
    195            windows: List of sliding window dictionaries
    196            fs: Sampling frequency
    197            **kwargs: Additional arguments for feature extraction
    198
    199        Returns:
    200            List of feature dictionaries
    201        """
    202        extractor = self.get_cached_instance(extractor_name, extractor_name, f"{extractor_name} feature extractor")
    203        return extractor.extract_features(windows, fs, **kwargs)

Extract features using the specified extractor.

Args: extractor_name: Name of the feature extractor windows: List of sliding window dictionaries fs: Sampling frequency **kwargs: Additional arguments for feature extraction

Returns: List of feature dictionaries

##### Inherited Members

BaseManager
  register
  unregister
  get_available_components
  get_component_info
  create_instance
  get_cached_instance

class PreprocessingManager(BaseManager): View Source

    206class PreprocessingManager(BaseManager):
    207    """
    208    Singleton manager for preprocessors.
    209    """
    210
    211    def register_preprocessor(self, name: str, preprocessor_class: Type[BasePreprocessor]):
    212        """
    213        Register a preprocessor.
    214
    215        Args:
    216            name: Name to register the preprocessor under
    217            preprocessor_class: Preprocessor class
    218        """
    219        if not issubclass(preprocessor_class, BasePreprocessor):
    220            raise ValueError(f"Preprocessor class must inherit from BasePreprocessor")
    221        self.register(name, preprocessor_class)
    222
    223    def preprocess_data(self, preprocessor_name: str, data: Any, **kwargs) -> Any:
    224        """
    225        Preprocess data using the specified preprocessor.
    226
    227        Args:
    228            preprocessor_name: Name of the preprocessor
    229            data: Input data to preprocess
    230            **kwargs: Additional arguments for preprocessing
    231
    232        Returns:
    233            Preprocessed data
    234        """
    235        preprocessor = self.get_cached_instance(preprocessor_name, preprocessor_name, f"{preprocessor_name} preprocessor")
    236        return preprocessor.fit_transform(data, **kwargs)

Singleton manager for preprocessors.

def register_preprocessor( self, name: str, preprocessor_class: Type[gaitsetpy.BasePreprocessor]): View Source

    211    def register_preprocessor(self, name: str, preprocessor_class: Type[BasePreprocessor]):
    212        """
    213        Register a preprocessor.
    214
    215        Args:
    216            name: Name to register the preprocessor under
    217            preprocessor_class: Preprocessor class
    218        """
    219        if not issubclass(preprocessor_class, BasePreprocessor):
    220            raise ValueError(f"Preprocessor class must inherit from BasePreprocessor")
    221        self.register(name, preprocessor_class)

Register a preprocessor.

Args: name: Name to register the preprocessor under preprocessor_class: Preprocessor class

def preprocess_data(self, preprocessor_name: str, data: Any, **kwargs) -> Any: View Source

    223    def preprocess_data(self, preprocessor_name: str, data: Any, **kwargs) -> Any:
    224        """
    225        Preprocess data using the specified preprocessor.
    226
    227        Args:
    228            preprocessor_name: Name of the preprocessor
    229            data: Input data to preprocess
    230            **kwargs: Additional arguments for preprocessing
    231
    232        Returns:
    233            Preprocessed data
    234        """
    235        preprocessor = self.get_cached_instance(preprocessor_name, preprocessor_name, f"{preprocessor_name} preprocessor")
    236        return preprocessor.fit_transform(data, **kwargs)

Preprocess data using the specified preprocessor.

Args: preprocessor_name: Name of the preprocessor data: Input data to preprocess **kwargs: Additional arguments for preprocessing

Returns: Preprocessed data

##### Inherited Members

BaseManager
  register
  unregister
  get_available_components
  get_component_info
  create_instance
  get_cached_instance

class EDAManager(BaseManager): View Source

    239class EDAManager(BaseManager):
    240    """
    241    Singleton manager for EDA analyzers.
    242    """
    243
    244    def register_analyzer(self, name: str, analyzer_class: Type[BaseEDAAnalyzer]):
    245        """
    246        Register an EDA analyzer.
    247
    248        Args:
    249            name: Name to register the analyzer under
    250            analyzer_class: EDA analyzer class
    251        """
    252        if not issubclass(analyzer_class, BaseEDAAnalyzer):
    253            raise ValueError(f"Analyzer class must inherit from BaseEDAAnalyzer")
    254        self.register(name, analyzer_class)
    255
    256    def analyze_data(self, analyzer_name: str, data: Any, **kwargs) -> Dict[str, Any]:
    257        """
    258        Analyze data using the specified analyzer.
    259
    260        Args:
    261            analyzer_name: Name of the EDA analyzer
    262            data: Input data to analyze
    263            **kwargs: Additional arguments for analysis
    264
    265        Returns:
    266            Analysis results dictionary
    267        """
    268        analyzer = self.get_cached_instance(analyzer_name, analyzer_name, f"{analyzer_name} analyzer")
    269        return analyzer.analyze(data, **kwargs)
    270
    271    def visualize_data(self, analyzer_name: str, data: Any, **kwargs):
    272        """
    273        Create visualizations using the specified analyzer.
    274
    275        Args:
    276            analyzer_name: Name of the EDA analyzer
    277            data: Input data to visualize
    278            **kwargs: Additional arguments for visualization
    279        """
    280        analyzer = self.get_cached_instance(analyzer_name, analyzer_name, f"{analyzer_name} analyzer")
    281        analyzer.visualize(data, **kwargs)

Singleton manager for EDA analyzers.

def register_analyzer( self, name: str, analyzer_class: Type[gaitsetpy.BaseEDAAnalyzer]): View Source

    244    def register_analyzer(self, name: str, analyzer_class: Type[BaseEDAAnalyzer]):
    245        """
    246        Register an EDA analyzer.
    247
    248        Args:
    249            name: Name to register the analyzer under
    250            analyzer_class: EDA analyzer class
    251        """
    252        if not issubclass(analyzer_class, BaseEDAAnalyzer):
    253            raise ValueError(f"Analyzer class must inherit from BaseEDAAnalyzer")
    254        self.register(name, analyzer_class)

Register an EDA analyzer.

Args: name: Name to register the analyzer under analyzer_class: EDA analyzer class

def analyze_data(self, analyzer_name: str, data: Any, **kwargs) -> Dict[str, Any]: View Source

    256    def analyze_data(self, analyzer_name: str, data: Any, **kwargs) -> Dict[str, Any]:
    257        """
    258        Analyze data using the specified analyzer.
    259
    260        Args:
    261            analyzer_name: Name of the EDA analyzer
    262            data: Input data to analyze
    263            **kwargs: Additional arguments for analysis
    264
    265        Returns:
    266            Analysis results dictionary
    267        """
    268        analyzer = self.get_cached_instance(analyzer_name, analyzer_name, f"{analyzer_name} analyzer")
    269        return analyzer.analyze(data, **kwargs)

Analyze data using the specified analyzer.

Args: analyzer_name: Name of the EDA analyzer data: Input data to analyze **kwargs: Additional arguments for analysis

Returns: Analysis results dictionary

def visualize_data(self, analyzer_name: str, data: Any, **kwargs): View Source

    271    def visualize_data(self, analyzer_name: str, data: Any, **kwargs):
    272        """
    273        Create visualizations using the specified analyzer.
    274
    275        Args:
    276            analyzer_name: Name of the EDA analyzer
    277            data: Input data to visualize
    278            **kwargs: Additional arguments for visualization
    279        """
    280        analyzer = self.get_cached_instance(analyzer_name, analyzer_name, f"{analyzer_name} analyzer")
    281        analyzer.visualize(data, **kwargs)

Create visualizations using the specified analyzer.

Args: analyzer_name: Name of the EDA analyzer data: Input data to visualize **kwargs: Additional arguments for visualization

##### Inherited Members

BaseManager
  register
  unregister
  get_available_components
  get_component_info
  create_instance
  get_cached_instance

class ClassificationManager(BaseManager): View Source

    284class ClassificationManager(BaseManager):
    285    """
    286    Singleton manager for classification models.
    287    """
    288
    289    def register_model(self, name: str, model_class: Type[BaseClassificationModel]):
    290        """
    291        Register a classification model.
    292
    293        Args:
    294            name: Name to register the model under
    295            model_class: Classification model class
    296        """
    297        if not issubclass(model_class, BaseClassificationModel):
    298            raise ValueError(f"Model class must inherit from BaseClassificationModel")
    299        self.register(name, model_class)
    300
    301    def train_model(self, model_name: str, features: List[Dict], **kwargs) -> BaseClassificationModel:
    302        """
    303        Train a classification model.
    304
    305        Args:
    306            model_name: Name of the classification model
    307            features: List of feature dictionaries
    308            **kwargs: Additional arguments for training
    309
    310        Returns:
    311            Trained model instance
    312        """
    313        model = self.create_instance(model_name, model_name, f"{model_name} classification model")
    314        model.train(features, **kwargs)
    315        return model
    316
    317    def predict(self, model_name: str, features: List[Dict], **kwargs) -> Any:
    318        """
    319        Make predictions using a trained model.
    320
    321        Args:
    322            model_name: Name of the classification model
    323            features: List of feature dictionaries
    324            **kwargs: Additional arguments for prediction
    325
    326        Returns:
    327            Predictions array
    328        """
    329        model = self.get_cached_instance(model_name, model_name, f"{model_name} classification model")
    330        return model.predict(features, **kwargs)
    331
    332    def evaluate_model(self, model_name: str, features: List[Dict], **kwargs) -> Dict[str, float]:
    333        """
    334        Evaluate a classification model.
    335
    336        Args:
    337            model_name: Name of the classification model
    338            features: List of feature dictionaries
    339            **kwargs: Additional arguments for evaluation
    340
    341        Returns:
    342            Evaluation metrics dictionary
    343        """
    344        model = self.get_cached_instance(model_name, model_name, f"{model_name} classification model")
    345        return model.evaluate(features, **kwargs)

Singleton manager for classification models.

def register_model( self, name: str, model_class: Type[gaitsetpy.BaseClassificationModel]): View Source

    289    def register_model(self, name: str, model_class: Type[BaseClassificationModel]):
    290        """
    291        Register a classification model.
    292
    293        Args:
    294            name: Name to register the model under
    295            model_class: Classification model class
    296        """
    297        if not issubclass(model_class, BaseClassificationModel):
    298            raise ValueError(f"Model class must inherit from BaseClassificationModel")
    299        self.register(name, model_class)

Register a classification model.

Args: name: Name to register the model under model_class: Classification model class

def train_model( self, model_name: str, features: List[Dict], **kwargs) -> gaitsetpy.BaseClassificationModel: View Source

    301    def train_model(self, model_name: str, features: List[Dict], **kwargs) -> BaseClassificationModel:
    302        """
    303        Train a classification model.
    304
    305        Args:
    306            model_name: Name of the classification model
    307            features: List of feature dictionaries
    308            **kwargs: Additional arguments for training
    309
    310        Returns:
    311            Trained model instance
    312        """
    313        model = self.create_instance(model_name, model_name, f"{model_name} classification model")
    314        model.train(features, **kwargs)
    315        return model

Train a classification model.

Args: model_name: Name of the classification model features: List of feature dictionaries **kwargs: Additional arguments for training

Returns: Trained model instance

def predict(self, model_name: str, features: List[Dict], **kwargs) -> Any: View Source

    317    def predict(self, model_name: str, features: List[Dict], **kwargs) -> Any:
    318        """
    319        Make predictions using a trained model.
    320
    321        Args:
    322            model_name: Name of the classification model
    323            features: List of feature dictionaries
    324            **kwargs: Additional arguments for prediction
    325
    326        Returns:
    327            Predictions array
    328        """
    329        model = self.get_cached_instance(model_name, model_name, f"{model_name} classification model")
    330        return model.predict(features, **kwargs)

Make predictions using a trained model.

Args: model_name: Name of the classification model features: List of feature dictionaries **kwargs: Additional arguments for prediction

Returns: Predictions array

def evaluate_model( self, model_name: str, features: List[Dict], **kwargs) -> Dict[str, float]: View Source

    332    def evaluate_model(self, model_name: str, features: List[Dict], **kwargs) -> Dict[str, float]:
    333        """
    334        Evaluate a classification model.
    335
    336        Args:
    337            model_name: Name of the classification model
    338            features: List of feature dictionaries
    339            **kwargs: Additional arguments for evaluation
    340
    341        Returns:
    342            Evaluation metrics dictionary
    343        """
    344        model = self.get_cached_instance(model_name, model_name, f"{model_name} classification model")
    345        return model.evaluate(features, **kwargs)

Evaluate a classification model.

Args: model_name: Name of the classification model features: List of feature dictionaries **kwargs: Additional arguments for evaluation

Returns: Evaluation metrics dictionary

##### Inherited Members

BaseManager
  register
  unregister
  get_available_components
  get_component_info
  create_instance
  get_cached_instance