gaitsetpy.core

Core module for GaitSetPy - Contains base classes and singleton managers for modular architecture.

This module provides:

  • Base classes for different components (DatasetLoader, FeatureExtractor, etc.)
  • Singleton managers for plugin-based architecture
  • Registry system for easy extension

Maintainer: @aharshit123456

 1"""
 2Core module for GaitSetPy - Contains base classes and singleton managers for modular architecture.
 3
 4This module provides:
 5- Base classes for different components (DatasetLoader, FeatureExtractor, etc.)
 6- Singleton managers for plugin-based architecture
 7- Registry system for easy extension
 8
 9Maintainer: @aharshit123456
10"""
11
12from .base_classes import (
13    BaseDatasetLoader,
14    BaseFeatureExtractor,
15    BasePreprocessor,
16    BaseEDAAnalyzer,
17    BaseClassificationModel
18)
19
20from .managers import (
21    DatasetManager,
22    FeatureManager,
23    PreprocessingManager,
24    EDAManager,
25    ClassificationManager
26)
27
28__all__ = [
29    'BaseDatasetLoader',
30    'BaseFeatureExtractor',
31    'BasePreprocessor',
32    'BaseEDAAnalyzer',
33    'BaseClassificationModel',
34    'DatasetManager',
35    'FeatureManager',
36    'PreprocessingManager',
37    'EDAManager',
38    'ClassificationManager'
39] 
class BaseDatasetLoader(abc.ABC):
17class BaseDatasetLoader(ABC):
18    """
19    Base class for all dataset loaders.
20    
21    All dataset loaders should inherit from this class and implement the required methods.
22    """
23    
24    def __init__(self, name: str, description: str = ""):
25        """
26        Initialize the dataset loader.
27        
28        Args:
29            name: Name of the dataset
30            description: Description of the dataset
31        """
32        self.name = name
33        self.description = description
34        self.data = None
35        self.metadata = {}
36    
37    @abstractmethod
38    def load_data(self, data_dir: str, **kwargs) -> Tuple[List[pd.DataFrame], List[str]]:
39        """
40        Load dataset from the specified directory.
41        
42        Args:
43            data_dir: Directory containing the dataset
44            **kwargs: Additional arguments specific to the dataset
45            
46        Returns:
47            Tuple of (data_list, names_list)
48        """
49        pass
50    
51    @abstractmethod
52    def create_sliding_windows(self, data: List[pd.DataFrame], names: List[str], 
53                             window_size: int = 192, step_size: int = 32) -> List[Dict]:
54        """
55        Create sliding windows from the loaded data.
56        
57        Args:
58            data: List of DataFrames
59            names: List of names corresponding to the data
60            window_size: Size of each sliding window
61            step_size: Step size for sliding windows
62            
63        Returns:
64            List of dictionaries containing sliding windows
65        """
66        pass
67    
68    @abstractmethod
69    def get_supported_formats(self) -> List[str]:
70        """
71        Get list of supported file formats.
72        
73        Returns:
74            List of supported file extensions
75        """
76        pass
77    
78    def get_info(self) -> Dict[str, Any]:
79        """
80        Get information about the dataset.
81        
82        Returns:
83            Dictionary containing dataset information
84        """
85        return {
86            'name': self.name,
87            'description': self.description,
88            'metadata': self.metadata,
89            'supported_formats': self.get_supported_formats()
90        }

Base class for all dataset loaders.

All dataset loaders should inherit from this class and implement the required methods.

BaseDatasetLoader(name: str, description: str = '')
24    def __init__(self, name: str, description: str = ""):
25        """
26        Initialize the dataset loader.
27        
28        Args:
29            name: Name of the dataset
30            description: Description of the dataset
31        """
32        self.name = name
33        self.description = description
34        self.data = None
35        self.metadata = {}

Initialize the dataset loader.

Args: name: Name of the dataset description: Description of the dataset

name
description
data
metadata
@abstractmethod
def load_data( self, data_dir: str, **kwargs) -> Tuple[List[pandas.core.frame.DataFrame], List[str]]:
37    @abstractmethod
38    def load_data(self, data_dir: str, **kwargs) -> Tuple[List[pd.DataFrame], List[str]]:
39        """
40        Load dataset from the specified directory.
41        
42        Args:
43            data_dir: Directory containing the dataset
44            **kwargs: Additional arguments specific to the dataset
45            
46        Returns:
47            Tuple of (data_list, names_list)
48        """
49        pass

Load dataset from the specified directory.

Args: data_dir: Directory containing the dataset **kwargs: Additional arguments specific to the dataset

Returns: Tuple of (data_list, names_list)

@abstractmethod
def create_sliding_windows( self, data: List[pandas.core.frame.DataFrame], names: List[str], window_size: int = 192, step_size: int = 32) -> List[Dict]:
51    @abstractmethod
52    def create_sliding_windows(self, data: List[pd.DataFrame], names: List[str], 
53                             window_size: int = 192, step_size: int = 32) -> List[Dict]:
54        """
55        Create sliding windows from the loaded data.
56        
57        Args:
58            data: List of DataFrames
59            names: List of names corresponding to the data
60            window_size: Size of each sliding window
61            step_size: Step size for sliding windows
62            
63        Returns:
64            List of dictionaries containing sliding windows
65        """
66        pass

Create sliding windows from the loaded data.

Args: data: List of DataFrames names: List of names corresponding to the data window_size: Size of each sliding window step_size: Step size for sliding windows

Returns: List of dictionaries containing sliding windows

@abstractmethod
def get_supported_formats(self) -> List[str]:
68    @abstractmethod
69    def get_supported_formats(self) -> List[str]:
70        """
71        Get list of supported file formats.
72        
73        Returns:
74            List of supported file extensions
75        """
76        pass

Get list of supported file formats.

Returns: List of supported file extensions

def get_info(self) -> Dict[str, Any]:
78    def get_info(self) -> Dict[str, Any]:
79        """
80        Get information about the dataset.
81        
82        Returns:
83            Dictionary containing dataset information
84        """
85        return {
86            'name': self.name,
87            'description': self.description,
88            'metadata': self.metadata,
89            'supported_formats': self.get_supported_formats()
90        }

Get information about the dataset.

Returns: Dictionary containing dataset information

class BaseFeatureExtractor(abc.ABC):
 93class BaseFeatureExtractor(ABC):
 94    """
 95    Base class for all feature extractors.
 96    
 97    All feature extractors should inherit from this class and implement the required methods.
 98    """
 99    
100    def __init__(self, name: str, description: str = ""):
101        """
102        Initialize the feature extractor.
103        
104        Args:
105            name: Name of the feature extractor
106            description: Description of the feature extractor
107        """
108        self.name = name
109        self.description = description
110        self.config = {}
111    
112    @abstractmethod
113    def extract_features(self, windows: List[Dict], fs: int, **kwargs) -> List[Dict]:
114        """
115        Extract features from sliding windows.
116        
117        Args:
118            windows: List of sliding window dictionaries
119            fs: Sampling frequency
120            **kwargs: Additional arguments for feature extraction
121            
122        Returns:
123            List of feature dictionaries
124        """
125        pass
126    
127    @abstractmethod
128    def get_feature_names(self) -> List[str]:
129        """
130        Get names of features extracted by this extractor.
131        
132        Returns:
133            List of feature names
134        """
135        pass
136    
137    def configure(self, config: Dict[str, Any]):
138        """
139        Configure the feature extractor.
140        
141        Args:
142            config: Configuration dictionary
143        """
144        self.config.update(config)
145    
146    def get_info(self) -> Dict[str, Any]:
147        """
148        Get information about the feature extractor.
149        
150        Returns:
151            Dictionary containing feature extractor information
152        """
153        return {
154            'name': self.name,
155            'description': self.description,
156            'config': self.config,
157            'feature_names': self.get_feature_names()
158        }

Base class for all feature extractors.

All feature extractors should inherit from this class and implement the required methods.

BaseFeatureExtractor(name: str, description: str = '')
100    def __init__(self, name: str, description: str = ""):
101        """
102        Initialize the feature extractor.
103        
104        Args:
105            name: Name of the feature extractor
106            description: Description of the feature extractor
107        """
108        self.name = name
109        self.description = description
110        self.config = {}

Initialize the feature extractor.

Args: name: Name of the feature extractor description: Description of the feature extractor

name
description
config
@abstractmethod
def extract_features(self, windows: List[Dict], fs: int, **kwargs) -> List[Dict]:
112    @abstractmethod
113    def extract_features(self, windows: List[Dict], fs: int, **kwargs) -> List[Dict]:
114        """
115        Extract features from sliding windows.
116        
117        Args:
118            windows: List of sliding window dictionaries
119            fs: Sampling frequency
120            **kwargs: Additional arguments for feature extraction
121            
122        Returns:
123            List of feature dictionaries
124        """
125        pass

Extract features from sliding windows.

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

Returns: List of feature dictionaries

@abstractmethod
def get_feature_names(self) -> List[str]:
127    @abstractmethod
128    def get_feature_names(self) -> List[str]:
129        """
130        Get names of features extracted by this extractor.
131        
132        Returns:
133            List of feature names
134        """
135        pass

Get names of features extracted by this extractor.

Returns: List of feature names

def configure(self, config: Dict[str, Any]):
137    def configure(self, config: Dict[str, Any]):
138        """
139        Configure the feature extractor.
140        
141        Args:
142            config: Configuration dictionary
143        """
144        self.config.update(config)

Configure the feature extractor.

Args: config: Configuration dictionary

def get_info(self) -> Dict[str, Any]:
146    def get_info(self) -> Dict[str, Any]:
147        """
148        Get information about the feature extractor.
149        
150        Returns:
151            Dictionary containing feature extractor information
152        """
153        return {
154            'name': self.name,
155            'description': self.description,
156            'config': self.config,
157            'feature_names': self.get_feature_names()
158        }

Get information about the feature extractor.

Returns: Dictionary containing feature extractor information

class BasePreprocessor(abc.ABC):
161class BasePreprocessor(ABC):
162    """
163    Base class for all preprocessors.
164    
165    All preprocessors should inherit from this class and implement the required methods.
166    """
167    
168    def __init__(self, name: str, description: str = ""):
169        """
170        Initialize the preprocessor.
171        
172        Args:
173            name: Name of the preprocessor
174            description: Description of the preprocessor
175        """
176        self.name = name
177        self.description = description
178        self.config = {}
179        self.fitted = False
180    
181    @abstractmethod
182    def fit(self, data: Union[pd.DataFrame, np.ndarray], **kwargs):
183        """
184        Fit the preprocessor to the data.
185        
186        Args:
187            data: Input data to fit on
188            **kwargs: Additional arguments for fitting
189        """
190        pass
191    
192    @abstractmethod
193    def transform(self, data: Union[pd.DataFrame, np.ndarray], **kwargs) -> Union[pd.DataFrame, np.ndarray]:
194        """
195        Transform the data using the fitted preprocessor.
196        
197        Args:
198            data: Input data to transform
199            **kwargs: Additional arguments for transformation
200            
201        Returns:
202            Transformed data
203        """
204        pass
205    
206    def fit_transform(self, data: Union[pd.DataFrame, np.ndarray], **kwargs) -> Union[pd.DataFrame, np.ndarray]:
207        """
208        Fit the preprocessor and transform the data.
209        
210        Args:
211            data: Input data to fit and transform
212            **kwargs: Additional arguments
213            
214        Returns:
215            Transformed data
216        """
217        self.fit(data, **kwargs)
218        return self.transform(data, **kwargs)
219    
220    def configure(self, config: Dict[str, Any]):
221        """
222        Configure the preprocessor.
223        
224        Args:
225            config: Configuration dictionary
226        """
227        self.config.update(config)
228    
229    def get_info(self) -> Dict[str, Any]:
230        """
231        Get information about the preprocessor.
232        
233        Returns:
234            Dictionary containing preprocessor information
235        """
236        return {
237            'name': self.name,
238            'description': self.description,
239            'config': self.config,
240            'fitted': self.fitted
241        }

Base class for all preprocessors.

All preprocessors should inherit from this class and implement the required methods.

BasePreprocessor(name: str, description: str = '')
168    def __init__(self, name: str, description: str = ""):
169        """
170        Initialize the preprocessor.
171        
172        Args:
173            name: Name of the preprocessor
174            description: Description of the preprocessor
175        """
176        self.name = name
177        self.description = description
178        self.config = {}
179        self.fitted = False

Initialize the preprocessor.

Args: name: Name of the preprocessor description: Description of the preprocessor

name
description
config
fitted
@abstractmethod
def fit( self, data: Union[pandas.core.frame.DataFrame, numpy.ndarray], **kwargs):
181    @abstractmethod
182    def fit(self, data: Union[pd.DataFrame, np.ndarray], **kwargs):
183        """
184        Fit the preprocessor to the data.
185        
186        Args:
187            data: Input data to fit on
188            **kwargs: Additional arguments for fitting
189        """
190        pass

Fit the preprocessor to the data.

Args: data: Input data to fit on **kwargs: Additional arguments for fitting

@abstractmethod
def transform( self, data: Union[pandas.core.frame.DataFrame, numpy.ndarray], **kwargs) -> Union[pandas.core.frame.DataFrame, numpy.ndarray]:
192    @abstractmethod
193    def transform(self, data: Union[pd.DataFrame, np.ndarray], **kwargs) -> Union[pd.DataFrame, np.ndarray]:
194        """
195        Transform the data using the fitted preprocessor.
196        
197        Args:
198            data: Input data to transform
199            **kwargs: Additional arguments for transformation
200            
201        Returns:
202            Transformed data
203        """
204        pass

Transform the data using the fitted preprocessor.

Args: data: Input data to transform **kwargs: Additional arguments for transformation

Returns: Transformed data

def fit_transform( self, data: Union[pandas.core.frame.DataFrame, numpy.ndarray], **kwargs) -> Union[pandas.core.frame.DataFrame, numpy.ndarray]:
206    def fit_transform(self, data: Union[pd.DataFrame, np.ndarray], **kwargs) -> Union[pd.DataFrame, np.ndarray]:
207        """
208        Fit the preprocessor and transform the data.
209        
210        Args:
211            data: Input data to fit and transform
212            **kwargs: Additional arguments
213            
214        Returns:
215            Transformed data
216        """
217        self.fit(data, **kwargs)
218        return self.transform(data, **kwargs)

Fit the preprocessor and transform the data.

Args: data: Input data to fit and transform **kwargs: Additional arguments

Returns: Transformed data

def configure(self, config: Dict[str, Any]):
220    def configure(self, config: Dict[str, Any]):
221        """
222        Configure the preprocessor.
223        
224        Args:
225            config: Configuration dictionary
226        """
227        self.config.update(config)

Configure the preprocessor.

Args: config: Configuration dictionary

def get_info(self) -> Dict[str, Any]:
229    def get_info(self) -> Dict[str, Any]:
230        """
231        Get information about the preprocessor.
232        
233        Returns:
234            Dictionary containing preprocessor information
235        """
236        return {
237            'name': self.name,
238            'description': self.description,
239            'config': self.config,
240            'fitted': self.fitted
241        }

Get information about the preprocessor.

Returns: Dictionary containing preprocessor information

class BaseEDAAnalyzer(abc.ABC):
244class BaseEDAAnalyzer(ABC):
245    """
246    Base class for all EDA analyzers.
247    
248    All EDA analyzers should inherit from this class and implement the required methods.
249    """
250    
251    def __init__(self, name: str, description: str = ""):
252        """
253        Initialize the EDA analyzer.
254        
255        Args:
256            name: Name of the EDA analyzer
257            description: Description of the EDA analyzer
258        """
259        self.name = name
260        self.description = description
261        self.config = {}
262    
263    @abstractmethod
264    def analyze(self, data: Union[pd.DataFrame, List[pd.DataFrame]], **kwargs) -> Dict[str, Any]:
265        """
266        Perform analysis on the data.
267        
268        Args:
269            data: Input data to analyze
270            **kwargs: Additional arguments for analysis
271            
272        Returns:
273            Dictionary containing analysis results
274        """
275        pass
276    
277    @abstractmethod
278    def visualize(self, data: Union[pd.DataFrame, List[pd.DataFrame]], **kwargs):
279        """
280        Create visualizations of the data.
281        
282        Args:
283            data: Input data to visualize
284            **kwargs: Additional arguments for visualization
285        """
286        pass
287    
288    def configure(self, config: Dict[str, Any]):
289        """
290        Configure the EDA analyzer.
291        
292        Args:
293            config: Configuration dictionary
294        """
295        self.config.update(config)
296    
297    def get_info(self) -> Dict[str, Any]:
298        """
299        Get information about the EDA analyzer.
300        
301        Returns:
302            Dictionary containing EDA analyzer information
303        """
304        return {
305            'name': self.name,
306            'description': self.description,
307            'config': self.config
308        }

Base class for all EDA analyzers.

All EDA analyzers should inherit from this class and implement the required methods.

BaseEDAAnalyzer(name: str, description: str = '')
251    def __init__(self, name: str, description: str = ""):
252        """
253        Initialize the EDA analyzer.
254        
255        Args:
256            name: Name of the EDA analyzer
257            description: Description of the EDA analyzer
258        """
259        self.name = name
260        self.description = description
261        self.config = {}

Initialize the EDA analyzer.

Args: name: Name of the EDA analyzer description: Description of the EDA analyzer

name
description
config
@abstractmethod
def analyze( self, data: Union[pandas.core.frame.DataFrame, List[pandas.core.frame.DataFrame]], **kwargs) -> Dict[str, Any]:
263    @abstractmethod
264    def analyze(self, data: Union[pd.DataFrame, List[pd.DataFrame]], **kwargs) -> Dict[str, Any]:
265        """
266        Perform analysis on the data.
267        
268        Args:
269            data: Input data to analyze
270            **kwargs: Additional arguments for analysis
271            
272        Returns:
273            Dictionary containing analysis results
274        """
275        pass

Perform analysis on the data.

Args: data: Input data to analyze **kwargs: Additional arguments for analysis

Returns: Dictionary containing analysis results

@abstractmethod
def visualize( self, data: Union[pandas.core.frame.DataFrame, List[pandas.core.frame.DataFrame]], **kwargs):
277    @abstractmethod
278    def visualize(self, data: Union[pd.DataFrame, List[pd.DataFrame]], **kwargs):
279        """
280        Create visualizations of the data.
281        
282        Args:
283            data: Input data to visualize
284            **kwargs: Additional arguments for visualization
285        """
286        pass

Create visualizations of the data.

Args: data: Input data to visualize **kwargs: Additional arguments for visualization

def configure(self, config: Dict[str, Any]):
288    def configure(self, config: Dict[str, Any]):
289        """
290        Configure the EDA analyzer.
291        
292        Args:
293            config: Configuration dictionary
294        """
295        self.config.update(config)

Configure the EDA analyzer.

Args: config: Configuration dictionary

def get_info(self) -> Dict[str, Any]:
297    def get_info(self) -> Dict[str, Any]:
298        """
299        Get information about the EDA analyzer.
300        
301        Returns:
302            Dictionary containing EDA analyzer information
303        """
304        return {
305            'name': self.name,
306            'description': self.description,
307            'config': self.config
308        }

Get information about the EDA analyzer.

Returns: Dictionary containing EDA analyzer information

class BaseClassificationModel(abc.ABC):
311class BaseClassificationModel(ABC):
312    """
313    Base class for all classification models.
314    
315    All classification models should inherit from this class and implement the required methods.
316    """
317    
318    def __init__(self, name: str, description: str = ""):
319        """
320        Initialize the classification model.
321        
322        Args:
323            name: Name of the classification model
324            description: Description of the classification model
325        """
326        self.name = name
327        self.description = description
328        self.model = None
329        self.config = {}
330        self.trained = False
331    
332    @abstractmethod
333    def train(self, features: List[Dict], **kwargs):
334        """
335        Train the classification model.
336        
337        Args:
338            features: List of feature dictionaries
339            **kwargs: Additional arguments for training
340        """
341        pass
342    
343    @abstractmethod
344    def predict(self, features: List[Dict], **kwargs) -> np.ndarray:
345        """
346        Make predictions using the trained model.
347        
348        Args:
349            features: List of feature dictionaries
350            **kwargs: Additional arguments for prediction
351            
352        Returns:
353            Array of predictions
354        """
355        pass
356    
357    @abstractmethod
358    def evaluate(self, features: List[Dict], **kwargs) -> Dict[str, float]:
359        """
360        Evaluate the model performance.
361        
362        Args:
363            features: List of feature dictionaries
364            **kwargs: Additional arguments for evaluation
365            
366        Returns:
367            Dictionary containing evaluation metrics
368        """
369        pass
370    
371    @abstractmethod
372    def save_model(self, filepath: str):
373        """
374        Save the trained model to a file.
375        
376        Args:
377            filepath: Path to save the model
378        """
379        pass
380    
381    @abstractmethod
382    def load_model(self, filepath: str):
383        """
384        Load a trained model from a file.
385        
386        Args:
387            filepath: Path to the saved model
388        """
389        pass
390    
391    def configure(self, config: Dict[str, Any]):
392        """
393        Configure the classification model.
394        
395        Args:
396            config: Configuration dictionary
397        """
398        self.config.update(config)
399    
400    def get_info(self) -> Dict[str, Any]:
401        """
402        Get information about the classification model.
403        
404        Returns:
405            Dictionary containing model information
406        """
407        return {
408            'name': self.name,
409            'description': self.description,
410            'config': self.config,
411            'trained': self.trained
412        } 

Base class for all classification models.

All classification models should inherit from this class and implement the required methods.

BaseClassificationModel(name: str, description: str = '')
318    def __init__(self, name: str, description: str = ""):
319        """
320        Initialize the classification model.
321        
322        Args:
323            name: Name of the classification model
324            description: Description of the classification model
325        """
326        self.name = name
327        self.description = description
328        self.model = None
329        self.config = {}
330        self.trained = False

Initialize the classification model.

Args: name: Name of the classification model description: Description of the classification model

name
description
model
config
trained
@abstractmethod
def train(self, features: List[Dict], **kwargs):
332    @abstractmethod
333    def train(self, features: List[Dict], **kwargs):
334        """
335        Train the classification model.
336        
337        Args:
338            features: List of feature dictionaries
339            **kwargs: Additional arguments for training
340        """
341        pass

Train the classification model.

Args: features: List of feature dictionaries **kwargs: Additional arguments for training

@abstractmethod
def predict(self, features: List[Dict], **kwargs) -> numpy.ndarray:
343    @abstractmethod
344    def predict(self, features: List[Dict], **kwargs) -> np.ndarray:
345        """
346        Make predictions using the trained model.
347        
348        Args:
349            features: List of feature dictionaries
350            **kwargs: Additional arguments for prediction
351            
352        Returns:
353            Array of predictions
354        """
355        pass

Make predictions using the trained model.

Args: features: List of feature dictionaries **kwargs: Additional arguments for prediction

Returns: Array of predictions

@abstractmethod
def evaluate(self, features: List[Dict], **kwargs) -> Dict[str, float]:
357    @abstractmethod
358    def evaluate(self, features: List[Dict], **kwargs) -> Dict[str, float]:
359        """
360        Evaluate the model performance.
361        
362        Args:
363            features: List of feature dictionaries
364            **kwargs: Additional arguments for evaluation
365            
366        Returns:
367            Dictionary containing evaluation metrics
368        """
369        pass

Evaluate the model performance.

Args: features: List of feature dictionaries **kwargs: Additional arguments for evaluation

Returns: Dictionary containing evaluation metrics

@abstractmethod
def save_model(self, filepath: str):
371    @abstractmethod
372    def save_model(self, filepath: str):
373        """
374        Save the trained model to a file.
375        
376        Args:
377            filepath: Path to save the model
378        """
379        pass

Save the trained model to a file.

Args: filepath: Path to save the model

@abstractmethod
def load_model(self, filepath: str):
381    @abstractmethod
382    def load_model(self, filepath: str):
383        """
384        Load a trained model from a file.
385        
386        Args:
387            filepath: Path to the saved model
388        """
389        pass

Load a trained model from a file.

Args: filepath: Path to the saved model

def configure(self, config: Dict[str, Any]):
391    def configure(self, config: Dict[str, Any]):
392        """
393        Configure the classification model.
394        
395        Args:
396            config: Configuration dictionary
397        """
398        self.config.update(config)

Configure the classification model.

Args: config: Configuration dictionary

def get_info(self) -> Dict[str, Any]:
400    def get_info(self) -> Dict[str, Any]:
401        """
402        Get information about the classification model.
403        
404        Returns:
405            Dictionary containing model information
406        """
407        return {
408            'name': self.name,
409            'description': self.description,
410            'config': self.config,
411            'trained': self.trained
412        } 

Get information about the classification model.

Returns: Dictionary containing model information

class DatasetManager(gaitsetpy.core.managers.BaseManager):
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[BaseDatasetLoader]):
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) -> BaseDatasetLoader:
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

class FeatureManager(gaitsetpy.core.managers.BaseManager):
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[BaseFeatureExtractor]):
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]:
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

class PreprocessingManager(gaitsetpy.core.managers.BaseManager):
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[BasePreprocessor]):
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:
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

class EDAManager(gaitsetpy.core.managers.BaseManager):
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[BaseEDAAnalyzer]):
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]:
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):
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

class ClassificationManager(gaitsetpy.core.managers.BaseManager):
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[BaseClassificationModel]):
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) -> BaseClassificationModel:
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:
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]:
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