| |
- builtins.object
-
- AutoRegressor
class AutoRegressor(builtins.object) |
|
AutoRegressor(all_kernels=False, tune_hyperparameters=False, tuning_method='random', tuning_iterations=10, cv=3, tuning_metric='r2')
A class to automatically select and evaluate the best regression 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='r2')
- Initializes the AutoRegressor.
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 ('r2', 'neg_mean_squared_error', 'rmse', 'mae', 'mape'). Default 'r2'.
Note: for minimization use 'neg_mean_squared_error', 'rmse', 'mae', 'mape'.
- evaluate(self, y_true, custom_metrics=None, model=None)
- Evaluates 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.
- fit(self, X_train, y_train, X_test=None, y_test=None, custom_metrics=None, verbose=False)
- Fits the regression 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.
verbose: (bool), optional - If True, prints progress. Default False.
Returns:
results: (list) - Performance metrics for each model.
predictions: (dict) - Predictions for each model on the test/train set.
- get_model(self, model_name)
- Returns the final fitted model instance (potentially tuned).
- 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.
Data descriptors defined here:
- __dict__
- dictionary for instance variables
- __weakref__
- list of weak references to the object
| |