sega_learn.utils.modelSelection

 
Modules
       
numpy

 
Classes
       
builtins.object
GridSearchCV
ModelSelectionUtility
RandomSearchCV
segaSearchCV

 
class GridSearchCV(builtins.object)
    GridSearchCV(model, param_grid, cv=5, metric='mse', direction='minimize')
 
Implements a grid search cross-validation for hyperparameter tuning.
 
  Methods defined here:
__init__(self, model, param_grid, cv=5, metric='mse', direction='minimize')
Initializes the GridSearchCV object.
 
Args:
    model: The model Object to be tuned.
    param_grid: (list) - A list of dictionaries containing hyperparameters to be tuned.
    cv: (int) - The number of folds for cross-validation. Default is 5.
    metric: (str) - The metric to be used for evaluation. Default is 'mse'.
        - Regression Metrics: 'mse', 'r2', 'mae', 'rmse', 'mape', 'mpe'
        - Classification Metrics: 'accuracy', 'precision', 'recall', 'f1', 'log_loss'
    direction: (str) - The direction to optimize the metric. Default is 'minimize'.
fit(self, X, y, verbose=False)
Fits the model to the data for all hyperparameter combinations.
 
Args:
    X: (numpy.ndarray) - The feature columns.
    y: (numpy.ndarray) - The label column.
    verbose: (bool) - A flag to display the training progress. Default is True.
 
Returns:
    model: The best model with the optimal hyperparameters.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class ModelSelectionUtility(builtins.object)
    A utility class for hyperparameter tuning and cross-validation of machine learning models.
 
  Static methods defined here:
cross_validate(model, X, y, params, cv=5, metric='mse', direction='minimize', verbose=False)
Implements a custom cross-validation for hyperparameter tuning.
 
Args:
    model: The model Object to be tuned.
    X: (numpy.ndarray) - The feature columns.
    y: (numpy.ndarray) - The label column.
    params: (dict) - The hyperparameters to be tuned.
    cv: (int) - The number of folds for cross-validation. Default is 5.
    metric: (str) - The metric to be used for evaluation. Default is 'mse'.
        - Regression Metrics: 'mse', 'r2', 'mae', 'rmse', 'mape', 'mpe'
        - Classification Metrics: 'accuracy', 'precision', 'recall', 'f1', 'log_loss'
    direction: (str) - The direction to optimize the metric. Default is 'minimize'.
    verbose: (bool) - A flag to display the training progress. Default is False.
 
Returns:
    tuple: A tuple containing the scores (list) and the trained model.
get_param_combinations(param_grid)
Generates all possible combinations of hyperparameters.
 
Returns:
    param_combinations (list): A list of dictionaries containing hyperparameter combinations.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class RandomSearchCV(builtins.object)
    RandomSearchCV(model, param_grid, iter=10, cv=5, metric='mse', direction='minimize')
 
Implements a random search cross-validation for hyperparameter tuning.
 
  Methods defined here:
__init__(self, model, param_grid, iter=10, cv=5, metric='mse', direction='minimize')
Initializes the RandomSearchCV object.
 
Args:
    model: The model Object to be tuned.
    param_grid: (list) - A list of dictionaries containing hyperparameters to be tuned.
    iter: (int) - The number of iterations for random search. Default is 10.
    cv: (int) - The number of folds for cross-validation. Default is 5.
    metric: (str) - The metric to be used for evaluation. Default is 'mse'.
        - Regression Metrics: 'mse', 'r2', 'mae', 'rmse', 'mape', 'mpe'
        - Classification Metrics: 'accuracy', 'precision', 'recall', 'f1', 'log_loss'
    direction: (str) - The direction to optimize the metric. Default is 'minimize'.
fit(self, X, y, verbose=False)
Fits the model to the data for iter random hyperparameter combinations.
 
Args:
    X: (numpy.ndarray) - The feature columns.
    y: (numpy.ndarray) - The label column.
    verbose: (bool) - A flag to display the training progress. Default is True.
 
Returns:
    model: The best model with the optimal hyperparameters.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class segaSearchCV(builtins.object)
    segaSearchCV(model, param_space, iter=10, cv=5, metric='mse', direction='minimize')
 
Implements a custom search cross-validation for hyperparameter tuning.
 
  Methods defined here:
__init__(self, model, param_space, iter=10, cv=5, metric='mse', direction='minimize')
Initializes the segaSearchCV object.
 
Args:
    model: The model Object to be tuned.
    param_space (list): A list of dictionaries containing hyperparameters to be tuned.
        Should be in the format: [{'param': [type, min, max]}, ...]
    iter (int): The number of iterations for random search. Default is 10.
    cv (int): The number of folds for cross-validation. Default is 5.
    metric (str): The metric to be used for evaluation. Default is 'mse'.
        - Regression Metrics: 'mse', 'r2', 'mae', 'rmse', 'mape', 'mpe'
        - Classification Metrics: 'accuracy', 'precision', 'recall', 'f1', 'log_loss'
    direction (str): The direction to optimize the metric. Default is 'minimize'.
fit(self, X, y, verbose=False)
Fits the model to the data for iter random hyperparameter combinations.
 
Args:
    X: (numpy.ndarray)- The feature columns.
    y: (numpy.ndarray)- The label column.
    verbose: (bool) - A flag to display the training progress. Default is True.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object