gaitsetpy.core.base_classes
Base classes for GaitSetPy components.
This module defines abstract base classes that all components should inherit from. Each base class defines the interface and common functionality for its respective component type.
Maintainer: @aharshit123456
1""" 2Base classes for GaitSetPy components. 3 4This module defines abstract base classes that all components should inherit from. 5Each base class defines the interface and common functionality for its respective component type. 6 7Maintainer: @aharshit123456 8""" 9 10from abc import ABC, abstractmethod 11from typing import Any, Dict, List, Optional, Tuple, Union 12import pandas as pd 13import numpy as np 14 15 16class BaseDatasetLoader(ABC): 17 """ 18 Base class for all dataset loaders. 19 20 All dataset loaders should inherit from this class and implement the required methods. 21 """ 22 23 def __init__(self, name: str, description: str = ""): 24 """ 25 Initialize the dataset loader. 26 27 Args: 28 name: Name of the dataset 29 description: Description of the dataset 30 """ 31 self.name = name 32 self.description = description 33 self.data = None 34 self.metadata = {} 35 36 @abstractmethod 37 def load_data(self, data_dir: str, **kwargs) -> Tuple[List[pd.DataFrame], List[str]]: 38 """ 39 Load dataset from the specified directory. 40 41 Args: 42 data_dir: Directory containing the dataset 43 **kwargs: Additional arguments specific to the dataset 44 45 Returns: 46 Tuple of (data_list, names_list) 47 """ 48 pass 49 50 @abstractmethod 51 def create_sliding_windows(self, data: List[pd.DataFrame], names: List[str], 52 window_size: int = 192, step_size: int = 32) -> List[Dict]: 53 """ 54 Create sliding windows from the loaded data. 55 56 Args: 57 data: List of DataFrames 58 names: List of names corresponding to the data 59 window_size: Size of each sliding window 60 step_size: Step size for sliding windows 61 62 Returns: 63 List of dictionaries containing sliding windows 64 """ 65 pass 66 67 @abstractmethod 68 def get_supported_formats(self) -> List[str]: 69 """ 70 Get list of supported file formats. 71 72 Returns: 73 List of supported file extensions 74 """ 75 pass 76 77 def get_info(self) -> Dict[str, Any]: 78 """ 79 Get information about the dataset. 80 81 Returns: 82 Dictionary containing dataset information 83 """ 84 return { 85 'name': self.name, 86 'description': self.description, 87 'metadata': self.metadata, 88 'supported_formats': self.get_supported_formats() 89 } 90 91 92class BaseFeatureExtractor(ABC): 93 """ 94 Base class for all feature extractors. 95 96 All feature extractors should inherit from this class and implement the required methods. 97 """ 98 99 def __init__(self, name: str, description: str = ""): 100 """ 101 Initialize the feature extractor. 102 103 Args: 104 name: Name of the feature extractor 105 description: Description of the feature extractor 106 """ 107 self.name = name 108 self.description = description 109 self.config = {} 110 111 @abstractmethod 112 def extract_features(self, windows: List[Dict], fs: int, **kwargs) -> List[Dict]: 113 """ 114 Extract features from sliding windows. 115 116 Args: 117 windows: List of sliding window dictionaries 118 fs: Sampling frequency 119 **kwargs: Additional arguments for feature extraction 120 121 Returns: 122 List of feature dictionaries 123 """ 124 pass 125 126 @abstractmethod 127 def get_feature_names(self) -> List[str]: 128 """ 129 Get names of features extracted by this extractor. 130 131 Returns: 132 List of feature names 133 """ 134 pass 135 136 def configure(self, config: Dict[str, Any]): 137 """ 138 Configure the feature extractor. 139 140 Args: 141 config: Configuration dictionary 142 """ 143 self.config.update(config) 144 145 def get_info(self) -> Dict[str, Any]: 146 """ 147 Get information about the feature extractor. 148 149 Returns: 150 Dictionary containing feature extractor information 151 """ 152 return { 153 'name': self.name, 154 'description': self.description, 155 'config': self.config, 156 'feature_names': self.get_feature_names() 157 } 158 159 160class BasePreprocessor(ABC): 161 """ 162 Base class for all preprocessors. 163 164 All preprocessors should inherit from this class and implement the required methods. 165 """ 166 167 def __init__(self, name: str, description: str = ""): 168 """ 169 Initialize the preprocessor. 170 171 Args: 172 name: Name of the preprocessor 173 description: Description of the preprocessor 174 """ 175 self.name = name 176 self.description = description 177 self.config = {} 178 self.fitted = False 179 180 @abstractmethod 181 def fit(self, data: Union[pd.DataFrame, np.ndarray], **kwargs): 182 """ 183 Fit the preprocessor to the data. 184 185 Args: 186 data: Input data to fit on 187 **kwargs: Additional arguments for fitting 188 """ 189 pass 190 191 @abstractmethod 192 def transform(self, data: Union[pd.DataFrame, np.ndarray], **kwargs) -> Union[pd.DataFrame, np.ndarray]: 193 """ 194 Transform the data using the fitted preprocessor. 195 196 Args: 197 data: Input data to transform 198 **kwargs: Additional arguments for transformation 199 200 Returns: 201 Transformed data 202 """ 203 pass 204 205 def fit_transform(self, data: Union[pd.DataFrame, np.ndarray], **kwargs) -> Union[pd.DataFrame, np.ndarray]: 206 """ 207 Fit the preprocessor and transform the data. 208 209 Args: 210 data: Input data to fit and transform 211 **kwargs: Additional arguments 212 213 Returns: 214 Transformed data 215 """ 216 self.fit(data, **kwargs) 217 return self.transform(data, **kwargs) 218 219 def configure(self, config: Dict[str, Any]): 220 """ 221 Configure the preprocessor. 222 223 Args: 224 config: Configuration dictionary 225 """ 226 self.config.update(config) 227 228 def get_info(self) -> Dict[str, Any]: 229 """ 230 Get information about the preprocessor. 231 232 Returns: 233 Dictionary containing preprocessor information 234 """ 235 return { 236 'name': self.name, 237 'description': self.description, 238 'config': self.config, 239 'fitted': self.fitted 240 } 241 242 243class BaseEDAAnalyzer(ABC): 244 """ 245 Base class for all EDA analyzers. 246 247 All EDA analyzers should inherit from this class and implement the required methods. 248 """ 249 250 def __init__(self, name: str, description: str = ""): 251 """ 252 Initialize the EDA analyzer. 253 254 Args: 255 name: Name of the EDA analyzer 256 description: Description of the EDA analyzer 257 """ 258 self.name = name 259 self.description = description 260 self.config = {} 261 262 @abstractmethod 263 def analyze(self, data: Union[pd.DataFrame, List[pd.DataFrame]], **kwargs) -> Dict[str, Any]: 264 """ 265 Perform analysis on the data. 266 267 Args: 268 data: Input data to analyze 269 **kwargs: Additional arguments for analysis 270 271 Returns: 272 Dictionary containing analysis results 273 """ 274 pass 275 276 @abstractmethod 277 def visualize(self, data: Union[pd.DataFrame, List[pd.DataFrame]], **kwargs): 278 """ 279 Create visualizations of the data. 280 281 Args: 282 data: Input data to visualize 283 **kwargs: Additional arguments for visualization 284 """ 285 pass 286 287 def configure(self, config: Dict[str, Any]): 288 """ 289 Configure the EDA analyzer. 290 291 Args: 292 config: Configuration dictionary 293 """ 294 self.config.update(config) 295 296 def get_info(self) -> Dict[str, Any]: 297 """ 298 Get information about the EDA analyzer. 299 300 Returns: 301 Dictionary containing EDA analyzer information 302 """ 303 return { 304 'name': self.name, 305 'description': self.description, 306 'config': self.config 307 } 308 309 310class BaseClassificationModel(ABC): 311 """ 312 Base class for all classification models. 313 314 All classification models should inherit from this class and implement the required methods. 315 """ 316 317 def __init__(self, name: str, description: str = ""): 318 """ 319 Initialize the classification model. 320 321 Args: 322 name: Name of the classification model 323 description: Description of the classification model 324 """ 325 self.name = name 326 self.description = description 327 self.model = None 328 self.config = {} 329 self.trained = False 330 331 @abstractmethod 332 def train(self, features: List[Dict], **kwargs): 333 """ 334 Train the classification model. 335 336 Args: 337 features: List of feature dictionaries 338 **kwargs: Additional arguments for training 339 """ 340 pass 341 342 @abstractmethod 343 def predict(self, features: List[Dict], **kwargs) -> np.ndarray: 344 """ 345 Make predictions using the trained model. 346 347 Args: 348 features: List of feature dictionaries 349 **kwargs: Additional arguments for prediction 350 351 Returns: 352 Array of predictions 353 """ 354 pass 355 356 @abstractmethod 357 def evaluate(self, features: List[Dict], **kwargs) -> Dict[str, float]: 358 """ 359 Evaluate the model performance. 360 361 Args: 362 features: List of feature dictionaries 363 **kwargs: Additional arguments for evaluation 364 365 Returns: 366 Dictionary containing evaluation metrics 367 """ 368 pass 369 370 @abstractmethod 371 def save_model(self, filepath: str): 372 """ 373 Save the trained model to a file. 374 375 Args: 376 filepath: Path to save the model 377 """ 378 pass 379 380 @abstractmethod 381 def load_model(self, filepath: str): 382 """ 383 Load a trained model from a file. 384 385 Args: 386 filepath: Path to the saved model 387 """ 388 pass 389 390 def configure(self, config: Dict[str, Any]): 391 """ 392 Configure the classification model. 393 394 Args: 395 config: Configuration dictionary 396 """ 397 self.config.update(config) 398 399 def get_info(self) -> Dict[str, Any]: 400 """ 401 Get information about the classification model. 402 403 Returns: 404 Dictionary containing model information 405 """ 406 return { 407 'name': self.name, 408 'description': self.description, 409 'config': self.config, 410 'trained': self.trained 411 }
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.
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
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)
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
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
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
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.
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
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
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
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
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
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.
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
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
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
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
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
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
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.
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
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
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
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
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
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.
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
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
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
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
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
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
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
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