Tune#
- class abil.tune.tune(X_train, y, model_config, regions=None)#
Bases:
object
A class for model training, hyperparameter tuning, and cross-validation.
- X_train#
The feature matrix used for training the models.
- Type:
pd.DataFrame
- y#
The target variable.
- Type:
pd.Series
- model_config#
Configuration dictionary containing model and training parameters.
- Type:
dict
- regions#
Name of the feature column representing regions, used for stratification (default is None).
- Type:
str or None, optional
- train(model, classifier=False, regressor=False, log="no"):
Train and tune models based on the provided configuration.
- train(model, classifier=False, regressor=False, log='no')#
Trains a machine learning model using the specified configuration.
- Parameters:
model (str) – The type of model to train. Supported options: - ‘rf’ : Random Forest - ‘knn’ : K-Nearest Neighbors - ‘xgb’ : XGBoost - ‘gp’ : Gaussian Process
classifier (bool, default=False) – Whether to train a classification model.
regressor (bool, default=False) – Whether to train a regression model.
log (str, default="no") – Log transformation option: - ‘yes’ : Apply log transformation to the target variable. - ‘no’ : No transformation. - ‘both’ : Train both with and without log transformation.
Examples
>>> m.train(model="rf", regressor=True)
- Return type:
None