| |
- builtins.object
-
- AutoClassifier
class AutoClassifier(builtins.object) |
|
AutoClassifier(all_kernels=False, tune_hyperparameters=False, tuning_method='random', tuning_iterations=10, cv=3, tuning_metric='f1')
A class to automatically select and evaluate the best classification model.
Includes optional automated hyperparameter tuning using GridSearchCV or RandomSearchCV. |
|
Methods defined here:
- __init__(self, all_kernels=False, tune_hyperparameters=False, tuning_method='random', tuning_iterations=10, cv=3, tuning_metric='f1')
- Initializes the AutoClassifier.
Args:
all_kernels (bool): If True, include all SVM kernels. Default False.
tune_hyperparameters (bool): If True, perform hyperparameter tuning. Default False.
tuning_method (str): Method for tuning ('random' or 'grid'). Default 'random'.
tuning_iterations (int): Number of iterations for Random Search. Default 10.
cv (int): Number of cross-validation folds for tuning. Default 3.
tuning_metric (str): Metric to optimize ('accuracy', 'precision', 'recall', 'f1'). Default 'f1'.
- evaluate(self, y_true, custom_metrics=None, model=None)
- Evaluates the performance using stored predictions.
Args:
y_true: (np.ndarray) - True target values.
custom_metrics: (dict), optional - Custom metrics. Default None.
model: (str), optional - Specific model name. Default None (evaluate all).
Returns:
dict: Evaluation metrics for the specified model(s).
- fit(self, X_train, y_train, X_test=None, y_test=None, custom_metrics=None, verbose=False)
- Fits the classification models, optionally performing hyperparameter tuning.
Args:
X_train: (np.ndarray) - Training feature data.
y_train: (np.ndarray) - Training target data.
X_test: (np.ndarray), optional - Testing feature data. Default None.
y_test: (np.ndarray), optional - Testing target data. Default None.
custom_metrics: (dict: str -> callable), optional - Custom metrics for evaluation.
verbose: (bool), optional - If True, prints progress. Default False.
Returns:
results: (list) - A list of dictionaries containing model performance metrics.
predictions: (dict) - A dictionary of predictions for each model on the test/train set.
- get_model(self, model_name)
- Returns the final fitted model instance (potentially tuned).
Args:
model_name (str): The name of the model.
Returns:
model_instance: The fitted model instance.
- predict(self, X, model=None)
- Generates predictions using fitted models.
Args:
X: (np.ndarray) - Input feature data.
model: (str), optional - Specific model name. Default None (predict with all).
Returns:
dict or np.ndarray: Predictions for specified model(s).
- summary(self)
- Prints a summary of model performance, including tuning results if available.
Data descriptors defined here:
- __dict__
- dictionary for instance variables
- __weakref__
- list of weak references to the object
| |