AutoGluon Tabular - Essential Functionality

Open In Colab Open In SageMaker Studio Lab

Via a simple fit() call, AutoGluon can produce highly-accurate models to predict the values in one column of a data table based on the rest of the columns’ values. Use AutoGluon with tabular data for both classification and regression problems. This tutorial demonstrates how to use AutoGluon to produce a classification model that predicts whether or not a person’s income exceeds $50,000.

TabularPredictor

To start, import AutoGluon’s TabularPredictor and TabularDataset classes:

from autogluon.tabular import TabularDataset, TabularPredictor

Load training data from a CSV file into an AutoGluon Dataset object. This object is essentially equivalent to a Pandas DataFrame and the same methods can be applied to both.

train_data = TabularDataset('https://autogluon.s3.amazonaws.com/datasets/Inc/train.csv')
subsample_size = 500  # subsample subset of data for faster demo, try setting this to much larger values
train_data = train_data.sample(n=subsample_size, random_state=0)
train_data.head()
age workclass fnlwgt education education-num marital-status occupation relationship race sex capital-gain capital-loss hours-per-week native-country class
6118 51 Private 39264 Some-college 10 Married-civ-spouse Exec-managerial Wife White Female 0 0 40 United-States >50K
23204 58 Private 51662 10th 6 Married-civ-spouse Other-service Wife White Female 0 0 8 United-States <=50K
29590 40 Private 326310 Some-college 10 Married-civ-spouse Craft-repair Husband White Male 0 0 44 United-States <=50K
18116 37 Private 222450 HS-grad 9 Never-married Sales Not-in-family White Male 0 2339 40 El-Salvador <=50K
33964 62 Private 109190 Bachelors 13 Married-civ-spouse Exec-managerial Husband White Male 15024 0 40 United-States >50K

Note that we loaded data from a CSV file stored in the cloud. You can also specify a local file-path instead if you have already downloaded the CSV file to your own machine (e.g., using wget). Each row in the table train_data corresponds to a single training example. In this particular dataset, each row corresponds to an individual person, and the columns contain various characteristics reported during a census.

Let’s first use these features to predict whether the person’s income exceeds $50,000 or not, which is recorded in the class column of this table.

label = 'class'
print(f"Unique classes: {list(train_data[label].unique())}")
Unique classes: [' >50K', ' <=50K']

AutoGluon works with raw data, meaning you don’t need to perform any data preprocessing before fitting AutoGluon. We actively recommend that you avoid performing operations such as missing value imputation or one-hot-encoding, as AutoGluon has dedicated logic to handle these situations automatically. You can learn more about AutoGluon’s preprocessing in the Feature Engineering Tutorial.

Training

Now we initialize and fit AutoGluon’s TabularPredictor in one line of code:

predictor = TabularPredictor(label=label).fit(train_data)
Hide code cell output
No path specified. Models will be saved in: "AutogluonModels/ag-20241004_184953"
Verbosity: 2 (Standard Logging)
=================== System Info ===================
AutoGluon Version:  1.1.2b20241004
Python Version:     3.10.13
Operating System:   Linux
Platform Machine:   x86_64
Platform Version:   #1 SMP Fri Jun 28 23:44:17 UTC 2024
CPU Count:          8
Memory Avail:       28.71 GB / 30.95 GB (92.8%)
Disk Space Avail:   213.43 GB / 255.99 GB (83.4%)
===================================================
No presets specified! To achieve strong results with AutoGluon, it is recommended to use the available presets. Defaulting to `'medium_quality'`...
	Recommended Presets (For more details refer to https://auto.gluon.ai/stable/tutorials/tabular/tabular-essentials.html#presets):
	presets='best_quality'   : Maximize accuracy. Recommended for most users. Use in competitions and benchmarks. Default time_limit=3600.
	presets='high_quality'   : Strong accuracy with fast inference speed. Default time_limit=3600.
	presets='good_quality'   : Good accuracy with very fast inference speed. Default time_limit=3600.
	presets='medium_quality' : Fast training time, ideal for initial prototyping.
Beginning AutoGluon training ...
AutoGluon will save models to "AutogluonModels/ag-20241004_184953"
Train Data Rows:    500
Train Data Columns: 14
Label Column:       class
AutoGluon infers your prediction problem is: 'binary' (because only two unique label-values observed).
2 unique label values:  [' >50K', ' <=50K']
If 'binary' is not the correct problem_type, please manually specify the problem_type parameter during Predictor init (You may specify problem_type as one of: ['binary', 'multiclass', 'regression', 'quantile'])
Problem Type:       binary
Preprocessing data ...
Selected class <--> label mapping:  class 1 =  >50K, class 0 =  <=50K
Note: For your binary classification, AutoGluon arbitrarily selected which label-value represents positive ( >50K) vs negative ( <=50K) class.
	To explicitly set the positive_class, either rename classes to 1 and 0, or specify positive_class in Predictor init.
Using Feature Generators to preprocess the data ...
Fitting AutoMLPipelineFeatureGenerator...
Available Memory:                    29398.03 MB
Train Data (Original)  Memory Usage: 0.28 MB (0.0% of available memory)
Inferring data type of each feature based on column values. Set feature_metadata_in to manually specify special dtypes of the features.
Stage 1 Generators:
Fitting AsTypeFeatureGenerator...
Note: Converting 1 features to boolean dtype as they only contain 2 unique values.
Stage 2 Generators:
Fitting FillNaFeatureGenerator...
Stage 3 Generators:
Fitting IdentityFeatureGenerator...
Fitting CategoryFeatureGenerator...
Fitting CategoryMemoryMinimizeFeatureGenerator...
Stage 4 Generators:
Fitting DropUniqueFeatureGenerator...
Stage 5 Generators:
Fitting DropDuplicatesFeatureGenerator...
Types of features in original data (raw dtype, special dtypes):
('int', [])    : 6 | ['age', 'fnlwgt', 'education-num', 'capital-gain', 'capital-loss', ...]
('object', []) : 8 | ['workclass', 'education', 'marital-status', 'occupation', 'relationship', ...]
Types of features in processed data (raw dtype, special dtypes):
('category', [])  : 7 | ['workclass', 'education', 'marital-status', 'occupation', 'relationship', ...]
('int', [])       : 6 | ['age', 'fnlwgt', 'education-num', 'capital-gain', 'capital-loss', ...]
('int', ['bool']) : 1 | ['sex']
0.1s = Fit runtime
14 features in original data used to generate 14 features in processed data.
Train Data (Processed) Memory Usage: 0.03 MB (0.0% of available memory)
Data preprocessing and feature engineering runtime = 0.09s ...
AutoGluon will gauge predictive performance using evaluation metric: 'accuracy'
To change this, specify the eval_metric parameter of Predictor()
Automatically generating train/validation split with holdout_frac=0.2, Train Rows: 400, Val Rows: 100
User-specified model hyperparameters to be fit:
{
	'NN_TORCH': [{}],
	'GBM': [{'extra_trees': True, 'ag_args': {'name_suffix': 'XT'}}, {}, {'learning_rate': 0.03, 'num_leaves': 128, 'feature_fraction': 0.9, 'min_data_in_leaf': 3, 'ag_args': {'name_suffix': 'Large', 'priority': 0, 'hyperparameter_tune_kwargs': None}}],
	'CAT': [{}],
	'XGB': [{}],
	'FASTAI': [{}],
	'RF': [{'criterion': 'gini', 'ag_args': {'name_suffix': 'Gini', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'entropy', 'ag_args': {'name_suffix': 'Entr', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'squared_error', 'ag_args': {'name_suffix': 'MSE', 'problem_types': ['regression', 'quantile']}}],
	'XT': [{'criterion': 'gini', 'ag_args': {'name_suffix': 'Gini', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'entropy', 'ag_args': {'name_suffix': 'Entr', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'squared_error', 'ag_args': {'name_suffix': 'MSE', 'problem_types': ['regression', 'quantile']}}],
	'KNN': [{'weights': 'uniform', 'ag_args': {'name_suffix': 'Unif'}}, {'weights': 'distance', 'ag_args': {'name_suffix': 'Dist'}}],
}
Fitting 13 L1 models ...
Fitting model: KNeighborsUnif ...
0.73	 = Validation score   (accuracy)
0.03s	 = Training   runtime
0.01s	 = Validation runtime
Fitting model: KNeighborsDist ...
0.65	 = Validation score   (accuracy)
0.01s	 = Training   runtime
0.01s	 = Validation runtime
Fitting model: LightGBMXT ...
0.83	 = Validation score   (accuracy)
0.39s	 = Training   runtime
0.0s	 = Validation runtime
Fitting model: LightGBM ...
0.85	 = Validation score   (accuracy)
0.24s	 = Training   runtime
0.0s	 = Validation runtime
Fitting model: RandomForestGini ...
0.84	 = Validation score   (accuracy)
0.58s	 = Training   runtime
0.05s	 = Validation runtime
Fitting model: RandomForestEntr ...
0.83	 = Validation score   (accuracy)
0.54s	 = Training   runtime
0.05s	 = Validation runtime
Fitting model: CatBoost ...
0.85	 = Validation score   (accuracy)
0.79s	 = Training   runtime
0.0s	 = Validation runtime
Fitting model: ExtraTreesGini ...
0.82	 = Validation score   (accuracy)
0.55s	 = Training   runtime
0.05s	 = Validation runtime
Fitting model: ExtraTreesEntr ...
0.81	 = Validation score   (accuracy)
0.53s	 = Training   runtime
0.05s	 = Validation runtime
Fitting model: NeuralNetFastAI ...
0.84	 = Validation score   (accuracy)
0.98s	 = Training   runtime
0.01s	 = Validation runtime
Fitting model: XGBoost ...
0.86	 = Validation score   (accuracy)
0.21s	 = Training   runtime
0.01s	 = Validation runtime
Fitting model: NeuralNetTorch ...
/home/ci/opt/venv/lib/python3.10/site-packages/sklearn/compose/_column_transformer.py:1623: FutureWarning: 
The format of the columns of the 'remainder' transformer in ColumnTransformer.transformers_ will change in version 1.7 to match the format of the other transformers.
At the moment the remainder columns are stored as indices (of type int). With the same ColumnTransformer configuration, in the future they will be stored as column names (of type str).
To use the new behavior now and suppress this warning, use ColumnTransformer(force_int_remainder_cols=False).

  warnings.warn(
0.83	 = Validation score   (accuracy)
2.04s	 = Training   runtime
0.01s	 = Validation runtime
Fitting model: LightGBMLarge ...
0.83	 = Validation score   (accuracy)
0.64s	 = Training   runtime
0.0s	 = Validation runtime
Fitting model: WeightedEnsemble_L2 ...
Ensemble Weights: {'XGBoost': 1.0}
0.86	 = Validation score   (accuracy)
0.09s	 = Training   runtime
0.0s	 = Validation runtime
AutoGluon training complete, total runtime = 8.11s ... Best model: WeightedEnsemble_L2 | Estimated inference throughput: 14695.7 rows/s (100 batch size)
TabularPredictor saved. To load, use: predictor = TabularPredictor.load("AutogluonModels/ag-20241004_184953")

That’s it! We now have a TabularPredictor that is able to make predictions on new data.

Prediction

Next, load separate test data to demonstrate how to make predictions on new examples at inference time:

test_data = TabularDataset('https://autogluon.s3.amazonaws.com/datasets/Inc/test.csv')
test_data.head()
Loaded data from: https://autogluon.s3.amazonaws.com/datasets/Inc/test.csv | Columns = 15 / 15 | Rows = 9769 -> 9769
age workclass fnlwgt education education-num marital-status occupation relationship race sex capital-gain capital-loss hours-per-week native-country class
0 31 Private 169085 11th 7 Married-civ-spouse Sales Wife White Female 0 0 20 United-States <=50K
1 17 Self-emp-not-inc 226203 12th 8 Never-married Sales Own-child White Male 0 0 45 United-States <=50K
2 47 Private 54260 Assoc-voc 11 Married-civ-spouse Exec-managerial Husband White Male 0 1887 60 United-States >50K
3 21 Private 176262 Some-college 10 Never-married Exec-managerial Own-child White Female 0 0 30 United-States <=50K
4 17 Private 241185 12th 8 Never-married Prof-specialty Own-child White Male 0 0 20 United-States <=50K

We can now use our trained models to make predictions on the new data:

y_pred = predictor.predict(test_data)
y_pred.head()  # Predictions
0     <=50K
1     <=50K
2      >50K
3     <=50K
4     <=50K
Name: class, dtype: object
y_pred_proba = predictor.predict_proba(test_data)
y_pred_proba.head()  # Prediction Probabilities
<=50K >50K
0 0.981126 0.018874
1 0.983599 0.016401
2 0.478133 0.521867
3 0.994751 0.005249
4 0.988539 0.011461

Evaluation

Next, we can evaluate the predictor on the (labeled) test data:

predictor.evaluate(test_data)
{'accuracy': 0.8409253761899887,
 'balanced_accuracy': 0.7475663839529563,
 'mcc': 0.5345297121913682,
 'roc_auc': 0.884716037791454,
 'f1': 0.6296472831267874,
 'precision': 0.7034078807241747,
 'recall': 0.5698878343399483}

We can also evaluate each model individually:

predictor.leaderboard(test_data)
model score_test score_val eval_metric pred_time_test pred_time_val fit_time pred_time_test_marginal pred_time_val_marginal fit_time_marginal stack_level can_infer fit_order
0 RandomForestGini 0.842870 0.84 accuracy 0.098390 0.048191 0.576451 0.098390 0.048191 0.576451 1 True 5
1 CatBoost 0.842461 0.85 accuracy 0.007973 0.004880 0.789126 0.007973 0.004880 0.789126 1 True 7
2 RandomForestEntr 0.841130 0.83 accuracy 0.098790 0.049052 0.540504 0.098790 0.049052 0.540504 1 True 6
3 XGBoost 0.840925 0.86 accuracy 0.037668 0.006006 0.209019 0.037668 0.006006 0.209019 1 True 11
4 WeightedEnsemble_L2 0.840925 0.86 accuracy 0.038932 0.006805 0.297158 0.001264 0.000798 0.088140 2 True 14
5 LightGBM 0.839799 0.85 accuracy 0.020124 0.004013 0.235260 0.020124 0.004013 0.235260 1 True 4
6 LightGBMXT 0.836421 0.83 accuracy 0.011642 0.003885 0.389326 0.011642 0.003885 0.389326 1 True 3
7 ExtraTreesGini 0.833862 0.82 accuracy 0.097429 0.047497 0.550596 0.097429 0.047497 0.550596 1 True 8
8 ExtraTreesEntr 0.833862 0.81 accuracy 0.099284 0.047800 0.525092 0.099284 0.047800 0.525092 1 True 9
9 NeuralNetTorch 0.833657 0.83 accuracy 0.045825 0.011153 2.043931 0.045825 0.011153 2.043931 1 True 12
10 NeuralNetFastAI 0.828949 0.84 accuracy 0.141952 0.009966 0.978025 0.141952 0.009966 0.978025 1 True 10
11 LightGBMLarge 0.817074 0.83 accuracy 0.012497 0.004592 0.640033 0.012497 0.004592 0.640033 1 True 13
12 KNeighborsUnif 0.725970 0.73 accuracy 0.026307 0.014569 0.034974 0.026307 0.014569 0.034974 1 True 1
13 KNeighborsDist 0.695158 0.65 accuracy 0.026713 0.013710 0.008855 0.026713 0.013710 0.008855 1 True 2

Loading a Trained Predictor

Finally, we can load the predictor in a new session (or new machine) by calling TabularPredictor.load() and specifying the location of the predictor artifact on disk.

predictor.path  # The path on disk where the predictor is saved
'AutogluonModels/ag-20241004_184953'
# Load the predictor by specifying the path it is saved to on disk.
# You can control where it is saved to by setting the `path` parameter during init
predictor = TabularPredictor.load(predictor.path)

Warning

TabularPredictor.load() uses the pickle module implicitly, which is known to be insecure. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling. Never load data that could have come from an untrusted source, or that could have been tampered with. Only load data you trust.

Now you’re ready to try AutoGluon on your own tabular datasets! As long as they’re stored in a popular format like CSV, you should be able to achieve strong predictive performance with just 2 lines of code:

from autogluon.tabular import TabularPredictor
predictor = TabularPredictor(label=<variable-name>).fit(train_data=<file-name>)

Note: This simple call to TabularPredictor.fit() is intended for your first prototype model. In a subsequent section, we’ll demonstrate how to maximize predictive performance by additionally specifying the presets parameter to fit() and the eval_metric parameter to TabularPredictor().

Description of fit()

Here we discuss what happened during fit().

Since there are only two possible values of the class variable, this was a binary classification problem, for which an appropriate performance metric is accuracy. AutoGluon automatically infers this as well as the type of each feature (i.e., which columns contain continuous numbers vs. discrete categories). AutoGluon can also automatically handle common issues like missing data and rescaling feature values.

We did not specify separate validation data and so AutoGluon automatically chose a random training/validation split of the data. The data used for validation is separated from the training data and is used to determine the models and hyperparameter-values that produce the best results. Rather than just a single model, AutoGluon trains multiple models and ensembles them together to obtain superior predictive performance.

By default, AutoGluon tries to fit various types of models including neural networks and tree ensembles. Each type of model has various hyperparameters, which traditionally, the user would have to specify. AutoGluon automates this process.

AutoGluon automatically and iteratively tests values for hyperparameters to produce the best performance on the validation data. This involves repeatedly training models under different hyperparameter settings and evaluating their performance. This process can be computationally-intensive, so fit() parallelizes this process across multiple threads using Ray. To control runtimes, you can specify various arguments in fit() such as time_limit as demonstrated in the subsequent In-Depth Tutorial.

We can view what properties AutoGluon automatically inferred about our prediction task:

print("AutoGluon infers problem type is: ", predictor.problem_type)
print("AutoGluon identified the following types of features:")
print(predictor.feature_metadata)
AutoGluon infers problem type is:  binary
AutoGluon identified the following types of features:
('category', [])  : 7 | ['workclass', 'education', 'marital-status', 'occupation', 'relationship', ...]
('int', [])       : 6 | ['age', 'fnlwgt', 'education-num', 'capital-gain', 'capital-loss', ...]
('int', ['bool']) : 1 | ['sex']

AutoGluon correctly recognized our prediction problem to be a binary classification task and decided that variables such as age should be represented as integers, whereas variables such as workclass should be represented as categorical objects. The feature_metadata attribute allows you to see the inferred data type of each predictive variable after preprocessing (this is its raw dtype; some features may also be associated with additional special dtypes if produced via feature-engineering, e.g. numerical representations of a datetime/text column).

To transform the data into AutoGluon’s internal representation, we can do the following:

test_data_transform = predictor.transform_features(test_data)
test_data_transform.head()
age fnlwgt education-num sex capital-gain capital-loss hours-per-week workclass education marital-status occupation relationship race native-country
0 31 169085 7 0 0 0 20 3 1 1 10 5 4 14
1 17 226203 8 1 0 0 45 5 2 3 10 3 4 14
2 47 54260 11 1 0 1887 60 3 7 1 3 0 4 14
3 21 176262 10 0 0 0 30 3 13 3 3 3 4 14
4 17 241185 8 1 0 0 20 3 2 3 8 3 4 14

Notice how the data is purely numeric after pre-processing (although categorical features will still be treated as categorical downstream).

To better understand our trained predictor, we can estimate the overall importance of each feature via TabularPredictor.feature_importance():

predictor.feature_importance(test_data)
Computing feature importance via permutation shuffling for 14 features using 5000 rows with 5 shuffle sets...
3.11s	= Expected runtime (0.62s per shuffle set)
2.23s	= Actual runtime (Completed 5 of 5 shuffle sets)
importance stddev p_value n p99_high p99_low
marital-status 0.05080 0.003792 3.698489e-06 5 0.058608 0.042992
capital-gain 0.03852 0.002318 1.565361e-06 5 0.043292 0.033748
education-num 0.02968 0.001346 5.063512e-07 5 0.032452 0.026908
age 0.01500 0.002850 1.490440e-04 5 0.020867 0.009133
hours-per-week 0.01172 0.003974 1.369430e-03 5 0.019902 0.003538
occupation 0.00528 0.001803 1.406849e-03 5 0.008993 0.001567
relationship 0.00472 0.001154 3.967984e-04 5 0.007096 0.002344
native-country 0.00144 0.000654 3.959537e-03 5 0.002787 0.000093
capital-loss 0.00128 0.000415 1.155921e-03 5 0.002134 0.000426
fnlwgt 0.00108 0.002361 1.820562e-01 5 0.005940 -0.003780
sex 0.00096 0.001090 6.012167e-02 5 0.003204 -0.001284
workclass 0.00092 0.001635 1.383281e-01 5 0.004286 -0.002446
education 0.00080 0.001463 1.442554e-01 5 0.003812 -0.002212
race 0.00048 0.000559 6.352320e-02 5 0.001630 -0.000670

The importance column is an estimate for the amount the evaluation metric score would drop if the feature were removed from the data. Negative values of importance mean that it is likely to improve the results if re-fit with the feature removed.

When we call predict(), AutoGluon automatically predicts with the model that displayed the best performance on validation data (i.e. the weighted-ensemble).

predictor.model_best
'WeightedEnsemble_L2'

We can instead specify which model to use for predictions like this:

predictor.predict(test_data, model='LightGBM')

You can get the list of trained models via .leaderboard() or .model_names():

predictor.model_names()
['KNeighborsUnif',
 'KNeighborsDist',
 'LightGBMXT',
 'LightGBM',
 'RandomForestGini',
 'RandomForestEntr',
 'CatBoost',
 'ExtraTreesGini',
 'ExtraTreesEntr',
 'NeuralNetFastAI',
 'XGBoost',
 'NeuralNetTorch',
 'LightGBMLarge',
 'WeightedEnsemble_L2']

The scores of predictive performance above were based on a default evaluation metric (accuracy for binary classification). Performance in certain applications may be measured by different metrics than the ones AutoGluon optimizes for by default. If you know the metric that counts in your application, you should specify it via the eval_metric argument as demonstrated in the next section.

Presets

AutoGluon comes with a variety of presets that can be specified in the call to .fit via the presets argument. medium_quality is used by default to encourage initial prototyping, but for serious usage, the other presets should be used instead.

Preset

Model Quality

Use Cases

Fit Time (Ideal)

Inference Time (Relative to medium_quality)

Disk Usage

best_quality

State-of-the-art (SOTA), much better than high_quality

When accuracy is what matters

16x+

32x+

16x+

high_quality

Better than good_quality

When a very powerful, portable solution with fast inference is required: Large-scale batch inference

16x+

4x

2x

good_quality

Stronger than any other AutoML Framework

When a powerful, highly portable solution with very fast inference is required: Billion-scale batch inference, sub-100ms online-inference, edge-devices

16x

2x

0.1x

medium_quality

Competitive with other top AutoML Frameworks

Initial prototyping, establishing a performance baseline

1x

1x

1x

We recommend users to start with medium_quality to get a sense of the problem and identify any data related issues. If medium_quality is taking too long to train, consider subsampling the training data during this prototyping phase.
Once you are comfortable, next try best_quality. Make sure to specify at least 16x the time_limit value as used in medium_quality. Once finished, you should have a very powerful solution that is often stronger than medium_quality.
Make sure to consider holding out test data that AutoGluon never sees during training to ensure that the models are performing as expected in terms of performance.
Once you evaluate both best_quality and medium_quality, check if either satisfies your needs. If neither do, consider trying high_quality and/or good_quality.
If none of the presets satisfy requirements, refer to Predicting Columns in a Table - In Depth for more advanced AutoGluon options.

Maximizing predictive performance

Note: You should not call fit() with entirely default arguments if you are benchmarking AutoGluon-Tabular or hoping to maximize its accuracy! To get the best predictive accuracy with AutoGluon, you should generally use it like this:

time_limit = 60  # for quick demonstration only, you should set this to longest time you are willing to wait (in seconds)
metric = 'roc_auc'  # specify your evaluation metric here
predictor = TabularPredictor(label, eval_metric=metric).fit(train_data, time_limit=time_limit, presets='best_quality')
Hide code cell output
(_ray_fit pid=7589) [1000]	valid_set's binary_logloss: 0.270008
(_ray_fit pid=7589) [2000]	valid_set's binary_logloss: 0.252973
No path specified. Models will be saved in: "AutogluonModels/ag-20241004_185005"
Verbosity: 2 (Standard Logging)
=================== System Info ===================
AutoGluon Version:  1.1.2b20241004
Python Version:     3.10.13
Operating System:   Linux
Platform Machine:   x86_64
Platform Version:   #1 SMP Fri Jun 28 23:44:17 UTC 2024
CPU Count:          8
Memory Avail:       28.46 GB / 30.95 GB (91.9%)
Disk Space Avail:   213.41 GB / 255.99 GB (83.4%)
===================================================
Presets specified: ['best_quality']
Setting dynamic_stacking from 'auto' to True. Reason: Enable dynamic_stacking when use_bag_holdout is disabled. (use_bag_holdout=False)
Stack configuration (auto_stack=True): num_stack_levels=1, num_bag_folds=8, num_bag_sets=1
DyStack is enabled (dynamic_stacking=True). AutoGluon will try to determine whether the input data is affected by stacked overfitting and enable or disable stacking as a consequence.
This is used to identify the optimal `num_stack_levels` value. Copies of AutoGluon will be fit on subsets of the data. Then holdout validation data is used to detect stacked overfitting.
Running DyStack for up to 15s of the 60s of remaining time (25%).
Running DyStack sub-fit in a ray process to avoid memory leakage. Enabling ray logging (enable_ray_logging=True). Specify `ds_args={'enable_ray_logging': False}` if you experience logging issues.
2024-10-04 18:50:08,139	INFO worker.py:1744 -- Started a local Ray instance. View the dashboard at 127.0.0.1:8265 
Context path: "AutogluonModels/ag-20241004_185005/ds_sub_fit/sub_fit_ho"
(_dystack pid=7190) Running DyStack sub-fit ...
(_dystack pid=7190) Beginning AutoGluon training ... Time limit = 12s
(_dystack pid=7190) AutoGluon will save models to "AutogluonModels/ag-20241004_185005/ds_sub_fit/sub_fit_ho"
(_dystack pid=7190) Train Data Rows:    444
(_dystack pid=7190) Train Data Columns: 14
(_dystack pid=7190) Label Column:       class
(_dystack pid=7190) Problem Type:       binary
(_dystack pid=7190) Preprocessing data ...
(_dystack pid=7190) Selected class <--> label mapping:  class 1 =  >50K, class 0 =  <=50K
(_dystack pid=7190) 	Note: For your binary classification, AutoGluon arbitrarily selected which label-value represents positive ( >50K) vs negative ( <=50K) class.
(_dystack pid=7190) 	To explicitly set the positive_class, either rename classes to 1 and 0, or specify positive_class in Predictor init.
(_dystack pid=7190) Using Feature Generators to preprocess the data ...
(_dystack pid=7190) Fitting AutoMLPipelineFeatureGenerator...
(_dystack pid=7190) 	Available Memory:                    28528.29 MB
(_dystack pid=7190) 	Train Data (Original)  Memory Usage: 0.25 MB (0.0% of available memory)
(_dystack pid=7190) 	Inferring data type of each feature based on column values. Set feature_metadata_in to manually specify special dtypes of the features.
(_dystack pid=7190) 	Stage 1 Generators:
(_dystack pid=7190) 		Fitting AsTypeFeatureGenerator...
(_dystack pid=7190) 			Note: Converting 1 features to boolean dtype as they only contain 2 unique values.
(_dystack pid=7190) 	Stage 2 Generators:
(_dystack pid=7190) 		Fitting FillNaFeatureGenerator...
(_dystack pid=7190) 	Stage 3 Generators:
(_dystack pid=7190) 		Fitting IdentityFeatureGenerator...
(_dystack pid=7190) 		Fitting CategoryFeatureGenerator...
(_dystack pid=7190) 			Fitting CategoryMemoryMinimizeFeatureGenerator...
(_dystack pid=7190) 	Stage 4 Generators:
(_dystack pid=7190) 		Fitting DropUniqueFeatureGenerator...
(_dystack pid=7190) 	Stage 5 Generators:
(_dystack pid=7190) 		Fitting DropDuplicatesFeatureGenerator...
(_dystack pid=7190) 	Types of features in original data (raw dtype, special dtypes):
(_dystack pid=7190) 		('int', [])    : 6 | ['age', 'fnlwgt', 'education-num', 'capital-gain', 'capital-loss', ...]
(_dystack pid=7190) 		('object', []) : 8 | ['workclass', 'education', 'marital-status', 'occupation', 'relationship', ...]
(_dystack pid=7190) 	Types of features in processed data (raw dtype, special dtypes):
(_dystack pid=7190) 		('category', [])  : 7 | ['workclass', 'education', 'marital-status', 'occupation', 'relationship', ...]
(_dystack pid=7190) 		('int', [])       : 6 | ['age', 'fnlwgt', 'education-num', 'capital-gain', 'capital-loss', ...]
(_dystack pid=7190) 		('int', ['bool']) : 1 | ['sex']
(_dystack pid=7190) 	0.1s = Fit runtime
(_dystack pid=7190) 	14 features in original data used to generate 14 features in processed data.
(_dystack pid=7190) 	Train Data (Processed) Memory Usage: 0.03 MB (0.0% of available memory)
(_dystack pid=7190) Data preprocessing and feature engineering runtime = 0.08s ...
(_dystack pid=7190) AutoGluon will gauge predictive performance using evaluation metric: 'roc_auc'
(_dystack pid=7190) 	This metric expects predicted probabilities rather than predicted class labels, so you'll need to use predict_proba() instead of predict()
(_dystack pid=7190) 	To change this, specify the eval_metric parameter of Predictor()
(_dystack pid=7190) Large model count detected (112 configs) ... Only displaying the first 3 models of each family. To see all, set `verbosity=3`.
(_dystack pid=7190) User-specified model hyperparameters to be fit:
(_dystack pid=7190) {
(_dystack pid=7190) 	'NN_TORCH': [{}, {'activation': 'elu', 'dropout_prob': 0.10077639529843717, 'hidden_size': 108, 'learning_rate': 0.002735937344002146, 'num_layers': 4, 'use_batchnorm': True, 'weight_decay': 1.356433327634438e-12, 'ag_args': {'name_suffix': '_r79', 'priority': -2}}, {'activation': 'elu', 'dropout_prob': 0.11897478034205347, 'hidden_size': 213, 'learning_rate': 0.0010474382260641949, 'num_layers': 4, 'use_batchnorm': False, 'weight_decay': 5.594471067786272e-10, 'ag_args': {'name_suffix': '_r22', 'priority': -7}}],
(_dystack pid=7190) 	'GBM': [{'extra_trees': True, 'ag_args': {'name_suffix': 'XT'}}, {}, {'learning_rate': 0.03, 'num_leaves': 128, 'feature_fraction': 0.9, 'min_data_in_leaf': 3, 'ag_args': {'name_suffix': 'Large', 'priority': 0, 'hyperparameter_tune_kwargs': None}}],
(_dystack pid=7190) 	'CAT': [{}, {'depth': 6, 'grow_policy': 'SymmetricTree', 'l2_leaf_reg': 2.1542798306067823, 'learning_rate': 0.06864209415792857, 'max_ctr_complexity': 4, 'one_hot_max_size': 10, 'ag_args': {'name_suffix': '_r177', 'priority': -1}}, {'depth': 8, 'grow_policy': 'Depthwise', 'l2_leaf_reg': 2.7997999596449104, 'learning_rate': 0.031375015734637225, 'max_ctr_complexity': 2, 'one_hot_max_size': 3, 'ag_args': {'name_suffix': '_r9', 'priority': -5}}],
(_dystack pid=7190) 	'XGB': [{}, {'colsample_bytree': 0.6917311125174739, 'enable_categorical': False, 'learning_rate': 0.018063876087523967, 'max_depth': 10, 'min_child_weight': 0.6028633586934382, 'ag_args': {'name_suffix': '_r33', 'priority': -8}}, {'colsample_bytree': 0.6628423832084077, 'enable_categorical': False, 'learning_rate': 0.08775715546881824, 'max_depth': 5, 'min_child_weight': 0.6294123374222513, 'ag_args': {'name_suffix': '_r89', 'priority': -16}}],
(_dystack pid=7190) 	'FASTAI': [{}, {'bs': 256, 'emb_drop': 0.5411770367537934, 'epochs': 43, 'layers': [800, 400], 'lr': 0.01519848858318159, 'ps': 0.23782946566604385, 'ag_args': {'name_suffix': '_r191', 'priority': -4}}, {'bs': 2048, 'emb_drop': 0.05070411322605811, 'epochs': 29, 'layers': [200, 100], 'lr': 0.08974235041576624, 'ps': 0.10393466140748028, 'ag_args': {'name_suffix': '_r102', 'priority': -11}}],
(_dystack pid=7190) 	'RF': [{'criterion': 'gini', 'ag_args': {'name_suffix': 'Gini', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'entropy', 'ag_args': {'name_suffix': 'Entr', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'squared_error', 'ag_args': {'name_suffix': 'MSE', 'problem_types': ['regression', 'quantile']}}],
(_dystack pid=7190) 	'XT': [{'criterion': 'gini', 'ag_args': {'name_suffix': 'Gini', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'entropy', 'ag_args': {'name_suffix': 'Entr', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'squared_error', 'ag_args': {'name_suffix': 'MSE', 'problem_types': ['regression', 'quantile']}}],
(_dystack pid=7190) 	'KNN': [{'weights': 'uniform', 'ag_args': {'name_suffix': 'Unif'}}, {'weights': 'distance', 'ag_args': {'name_suffix': 'Dist'}}],
(_dystack pid=7190) }
(_dystack pid=7190) AutoGluon will fit 2 stack levels (L1 to L2) ...
(_dystack pid=7190) Fitting 110 L1 models ...
(_dystack pid=7190) Fitting model: KNeighborsUnif_BAG_L1 ... Training model for up to 7.98s of the 11.97s of remaining time.
(_dystack pid=7190) 	0.5271	 = Validation score   (roc_auc)
(_dystack pid=7190) 	0.0s	 = Training   runtime
(_dystack pid=7190) 	0.02s	 = Validation runtime
(_dystack pid=7190) Fitting model: KNeighborsDist_BAG_L1 ... Training model for up to 7.93s of the 11.91s of remaining time.
(_dystack pid=7190) 	0.5389	 = Validation score   (roc_auc)
(_dystack pid=7190) 	0.0s	 = Training   runtime
(_dystack pid=7190) 	0.01s	 = Validation runtime
(_dystack pid=7190) Fitting model: LightGBMXT_BAG_L1 ... Training model for up to 7.9s of the 11.89s of remaining time.
(_dystack pid=7190) 	Fitting 8 child models (S1F1 - S1F8) | Fitting with ParallelLocalFoldFittingStrategy (8 workers, per: cpus=1, gpus=0, memory=0.01%)
(_dystack pid=7190) 	0.8895	 = Validation score   (roc_auc)
(_dystack pid=7190) 	1.13s	 = Training   runtime
(_dystack pid=7190) 	0.06s	 = Validation runtime
(_dystack pid=7190) Fitting model: LightGBM_BAG_L1 ... Training model for up to 2.0s of the 5.99s of remaining time.
(_dystack pid=7190) 	Fitting 8 child models (S1F1 - S1F8) | Fitting with ParallelLocalFoldFittingStrategy (8 workers, per: cpus=1, gpus=0, memory=0.01%)
(_dystack pid=7190) 	0.8693	 = Validation score   (roc_auc)
(_dystack pid=7190) 	0.7s	 = Training   runtime
(_dystack pid=7190) 	0.05s	 = Validation runtime
(_dystack pid=7190) Fitting model: WeightedEnsemble_L2 ... Training model for up to 11.98s of the 0.19s of remaining time.
(_dystack pid=7190) 	Ensemble Weights: {'LightGBMXT_BAG_L1': 1.0}
(_dystack pid=7190) 	0.8895	 = Validation score   (roc_auc)
(_dystack pid=7190) 	0.03s	 = Training   runtime
(_dystack pid=7190) 	0.0s	 = Validation runtime
(_dystack pid=7190) Fitting 108 L2 models ...
(_dystack pid=7190) Fitting model: LightGBMXT_BAG_L2 ... Training model for up to 0.13s of the 0.1s of remaining time.
(_dystack pid=7190) 	Fitting 8 child models (S1F1 - S1F8) | Fitting with ParallelLocalFoldFittingStrategy (8 workers, per: cpus=1, gpus=0, memory=0.01%)
(_dystack pid=7190) 	0.8011	 = Validation score   (roc_auc)
(_dystack pid=7190) 	0.52s	 = Training   runtime
(_dystack pid=7190) 	0.04s	 = Validation runtime
(_dystack pid=7190) Fitting model: WeightedEnsemble_L3 ... Training model for up to 11.98s of the -5.89s of remaining time.
(_dystack pid=7190) 	Ensemble Weights: {'LightGBMXT_BAG_L1': 1.0}
(_dystack pid=7190) 	0.8895	 = Validation score   (roc_auc)
(_dystack pid=7190) 	0.02s	 = Training   runtime
(_dystack pid=7190) 	0.0s	 = Validation runtime
(_dystack pid=7190) AutoGluon training complete, total runtime = 18.0s ... Best model: WeightedEnsemble_L2 | Estimated inference throughput: 961.3 rows/s (56 batch size)
(_dystack pid=7190) TabularPredictor saved. To load, use: predictor = TabularPredictor.load("AutogluonModels/ag-20241004_185005/ds_sub_fit/sub_fit_ho")
(_dystack pid=7190) Deleting DyStack predictor artifacts (clean_up_fits=True) ...
Leaderboard on holdout data (DyStack):
model  score_holdout  score_val eval_metric  pred_time_test  pred_time_val  fit_time  pred_time_test_marginal  pred_time_val_marginal  fit_time_marginal  stack_level  can_infer  fit_order
0      LightGBMXT_BAG_L1       0.918699   0.889480     roc_auc        0.592108       0.058157  1.126511                 0.592108                0.058157           1.126511            1       True          3
1    WeightedEnsemble_L3       0.918699   0.889480     roc_auc        0.593787       0.058676  1.143976                 0.001678                0.000519           0.017465            3       True          7
2    WeightedEnsemble_L2       0.918699   0.889480     roc_auc        0.594040       0.058914  1.152746                 0.001932                0.000757           0.026235            2       True          5
3        LightGBM_BAG_L1       0.897561   0.869264     roc_auc        0.074715       0.046862  0.697722                 0.074715                0.046862           0.697722            1       True          4
4      LightGBMXT_BAG_L2       0.841463   0.801119     roc_auc        0.646686       0.112152  1.645261                 0.039048                0.041080           0.515605            2       True          6
5  KNeighborsUnif_BAG_L1       0.573171   0.527070     roc_auc        0.015005       0.015580  0.003598                 0.015005                0.015580           0.003598            1       True          1
6  KNeighborsDist_BAG_L1       0.556098   0.538940     roc_auc        0.015530       0.012915  0.003145                 0.015530                0.012915           0.003145            1       True          2
1	 = Optimal   num_stack_levels (Stacked Overfitting Occurred: False)
25s	 = DyStack   runtime |	35s	 = Remaining runtime
Starting main fit with num_stack_levels=1.
	For future fit calls on this dataset, you can skip DyStack to save time: `predictor.fit(..., dynamic_stacking=False, num_stack_levels=1)`
Beginning AutoGluon training ... Time limit = 35s
AutoGluon will save models to "AutogluonModels/ag-20241004_185005"
Train Data Rows:    500
Train Data Columns: 14
Label Column:       class
Problem Type:       binary
Preprocessing data ...
Selected class <--> label mapping:  class 1 =  >50K, class 0 =  <=50K
Note: For your binary classification, AutoGluon arbitrarily selected which label-value represents positive ( >50K) vs negative ( <=50K) class.
	To explicitly set the positive_class, either rename classes to 1 and 0, or specify positive_class in Predictor init.
Using Feature Generators to preprocess the data ...
Fitting AutoMLPipelineFeatureGenerator...
Available Memory:                    27619.48 MB
Train Data (Original)  Memory Usage: 0.28 MB (0.0% of available memory)
Inferring data type of each feature based on column values. Set feature_metadata_in to manually specify special dtypes of the features.
Stage 1 Generators:
Fitting AsTypeFeatureGenerator...
Note: Converting 1 features to boolean dtype as they only contain 2 unique values.
Stage 2 Generators:
Fitting FillNaFeatureGenerator...
Stage 3 Generators:
Fitting IdentityFeatureGenerator...
Fitting CategoryFeatureGenerator...
Fitting CategoryMemoryMinimizeFeatureGenerator...
Stage 4 Generators:
Fitting DropUniqueFeatureGenerator...
Stage 5 Generators:
Fitting DropDuplicatesFeatureGenerator...
Types of features in original data (raw dtype, special dtypes):
('int', [])    : 6 | ['age', 'fnlwgt', 'education-num', 'capital-gain', 'capital-loss', ...]
('object', []) : 8 | ['workclass', 'education', 'marital-status', 'occupation', 'relationship', ...]
Types of features in processed data (raw dtype, special dtypes):
('category', [])  : 7 | ['workclass', 'education', 'marital-status', 'occupation', 'relationship', ...]
('int', [])       : 6 | ['age', 'fnlwgt', 'education-num', 'capital-gain', 'capital-loss', ...]
('int', ['bool']) : 1 | ['sex']
0.1s = Fit runtime
14 features in original data used to generate 14 features in processed data.
Train Data (Processed) Memory Usage: 0.03 MB (0.0% of available memory)
Data preprocessing and feature engineering runtime = 0.13s ...
AutoGluon will gauge predictive performance using evaluation metric: 'roc_auc'
This metric expects predicted probabilities rather than predicted class labels, so you'll need to use predict_proba() instead of predict()
To change this, specify the eval_metric parameter of Predictor()
Large model count detected (112 configs) ... Only displaying the first 3 models of each family. To see all, set `verbosity=3`.
User-specified model hyperparameters to be fit:
{
	'NN_TORCH': [{}, {'activation': 'elu', 'dropout_prob': 0.10077639529843717, 'hidden_size': 108, 'learning_rate': 0.002735937344002146, 'num_layers': 4, 'use_batchnorm': True, 'weight_decay': 1.356433327634438e-12, 'ag_args': {'name_suffix': '_r79', 'priority': -2}}, {'activation': 'elu', 'dropout_prob': 0.11897478034205347, 'hidden_size': 213, 'learning_rate': 0.0010474382260641949, 'num_layers': 4, 'use_batchnorm': False, 'weight_decay': 5.594471067786272e-10, 'ag_args': {'name_suffix': '_r22', 'priority': -7}}],
	'GBM': [{'extra_trees': True, 'ag_args': {'name_suffix': 'XT'}}, {}, {'learning_rate': 0.03, 'num_leaves': 128, 'feature_fraction': 0.9, 'min_data_in_leaf': 3, 'ag_args': {'name_suffix': 'Large', 'priority': 0, 'hyperparameter_tune_kwargs': None}}],
	'CAT': [{}, {'depth': 6, 'grow_policy': 'SymmetricTree', 'l2_leaf_reg': 2.1542798306067823, 'learning_rate': 0.06864209415792857, 'max_ctr_complexity': 4, 'one_hot_max_size': 10, 'ag_args': {'name_suffix': '_r177', 'priority': -1}}, {'depth': 8, 'grow_policy': 'Depthwise', 'l2_leaf_reg': 2.7997999596449104, 'learning_rate': 0.031375015734637225, 'max_ctr_complexity': 2, 'one_hot_max_size': 3, 'ag_args': {'name_suffix': '_r9', 'priority': -5}}],
	'XGB': [{}, {'colsample_bytree': 0.6917311125174739, 'enable_categorical': False, 'learning_rate': 0.018063876087523967, 'max_depth': 10, 'min_child_weight': 0.6028633586934382, 'ag_args': {'name_suffix': '_r33', 'priority': -8}}, {'colsample_bytree': 0.6628423832084077, 'enable_categorical': False, 'learning_rate': 0.08775715546881824, 'max_depth': 5, 'min_child_weight': 0.6294123374222513, 'ag_args': {'name_suffix': '_r89', 'priority': -16}}],
	'FASTAI': [{}, {'bs': 256, 'emb_drop': 0.5411770367537934, 'epochs': 43, 'layers': [800, 400], 'lr': 0.01519848858318159, 'ps': 0.23782946566604385, 'ag_args': {'name_suffix': '_r191', 'priority': -4}}, {'bs': 2048, 'emb_drop': 0.05070411322605811, 'epochs': 29, 'layers': [200, 100], 'lr': 0.08974235041576624, 'ps': 0.10393466140748028, 'ag_args': {'name_suffix': '_r102', 'priority': -11}}],
	'RF': [{'criterion': 'gini', 'ag_args': {'name_suffix': 'Gini', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'entropy', 'ag_args': {'name_suffix': 'Entr', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'squared_error', 'ag_args': {'name_suffix': 'MSE', 'problem_types': ['regression', 'quantile']}}],
	'XT': [{'criterion': 'gini', 'ag_args': {'name_suffix': 'Gini', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'entropy', 'ag_args': {'name_suffix': 'Entr', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'squared_error', 'ag_args': {'name_suffix': 'MSE', 'problem_types': ['regression', 'quantile']}}],
	'KNN': [{'weights': 'uniform', 'ag_args': {'name_suffix': 'Unif'}}, {'weights': 'distance', 'ag_args': {'name_suffix': 'Dist'}}],
}
AutoGluon will fit 2 stack levels (L1 to L2) ...
Fitting 110 L1 models ...
Fitting model: KNeighborsUnif_BAG_L1 ... Training model for up to 23.52s of the 35.28s of remaining time.
0.5196	 = Validation score   (roc_auc)
0.0s	 = Training   runtime
0.02s	 = Validation runtime
Fitting model: KNeighborsDist_BAG_L1 ... Training model for up to 23.5s of the 35.26s of remaining time.
0.537	 = Validation score   (roc_auc)
0.0s	 = Training   runtime
0.01s	 = Validation runtime
Fitting model: LightGBMXT_BAG_L1 ... Training model for up to 23.47s of the 35.23s of remaining time.
Fitting 8 child models (S1F1 - S1F8) | Fitting with ParallelLocalFoldFittingStrategy (8 workers, per: cpus=1, gpus=0, memory=0.01%)
0.8912	 = Validation score   (roc_auc)
0.97s	 = Training   runtime
0.06s	 = Validation runtime
Fitting model: LightGBM_BAG_L1 ... Training model for up to 17.79s of the 29.55s of remaining time.
Fitting 8 child models (S1F1 - S1F8) | Fitting with ParallelLocalFoldFittingStrategy (8 workers, per: cpus=1, gpus=0, memory=0.01%)
0.8799	 = Validation score   (roc_auc)
0.94s	 = Training   runtime
0.05s	 = Validation runtime
Fitting model: RandomForestGini_BAG_L1 ... Training model for up to 11.63s of the 23.39s of remaining time.
0.8879	 = Validation score   (roc_auc)
0.87s	 = Training   runtime
0.13s	 = Validation runtime
Fitting model: RandomForestEntr_BAG_L1 ... Training model for up to 10.61s of the 22.37s of remaining time.
0.8899	 = Validation score   (roc_auc)
0.52s	 = Training   runtime
0.1s	 = Validation runtime
Fitting model: CatBoost_BAG_L1 ... Training model for up to 9.98s of the 21.74s of remaining time.
Fitting 8 child models (S1F1 - S1F8) | Fitting with ParallelLocalFoldFittingStrategy (8 workers, per: cpus=1, gpus=0, memory=0.02%)
0.8902	 = Validation score   (roc_auc)
5.09s	 = Training   runtime
0.05s	 = Validation runtime
Fitting model: ExtraTreesGini_BAG_L1 ... Training model for up to 0.17s of the 11.93s of remaining time.
0.8958	 = Validation score   (roc_auc)
0.56s	 = Training   runtime
0.1s	 = Validation runtime
Fitting model: WeightedEnsemble_L2 ... Training model for up to 35.3s of the 11.12s of remaining time.
Ensemble Weights: {'ExtraTreesGini_BAG_L1': 0.6, 'LightGBMXT_BAG_L1': 0.2, 'CatBoost_BAG_L1': 0.2}
0.9041	 = Validation score   (roc_auc)
0.03s	 = Training   runtime
0.0s	 = Validation runtime
Fitting 108 L2 models ...
Fitting model: LightGBMXT_BAG_L2 ... Training model for up to 11.08s of the 11.05s of remaining time.
Fitting 8 child models (S1F1 - S1F8) | Fitting with ParallelLocalFoldFittingStrategy (8 workers, per: cpus=1, gpus=0, memory=0.01%)
0.8911	 = Validation score   (roc_auc)
0.81s	 = Training   runtime
0.06s	 = Validation runtime
Fitting model: LightGBM_BAG_L2 ... Training model for up to 5.49s of the 5.46s of remaining time.
Fitting 8 child models (S1F1 - S1F8) | Fitting with ParallelLocalFoldFittingStrategy (8 workers, per: cpus=1, gpus=0, memory=0.02%)
0.8703	 = Validation score   (roc_auc)
0.74s	 = Training   runtime
0.04s	 = Validation runtime
Fitting model: WeightedEnsemble_L3 ... Training model for up to 35.29s of the -0.78s of remaining time.
Ensemble Weights: {'ExtraTreesGini_BAG_L1': 0.6, 'LightGBMXT_BAG_L1': 0.2, 'CatBoost_BAG_L1': 0.2}
0.9041	 = Validation score   (roc_auc)
0.06s	 = Training   runtime
0.0s	 = Validation runtime
AutoGluon training complete, total runtime = 36.28s ... Best model: WeightedEnsemble_L2 | Estimated inference throughput: 530.4 rows/s (63 batch size)
TabularPredictor saved. To load, use: predictor = TabularPredictor.load("AutogluonModels/ag-20241004_185005")
predictor.leaderboard(test_data)
model score_test score_val eval_metric pred_time_test pred_time_val fit_time pred_time_test_marginal pred_time_val_marginal fit_time_marginal stack_level can_infer fit_order
0 CatBoost_BAG_L1 0.902618 0.890228 roc_auc 0.067598 0.048932 5.089782 0.067598 0.048932 5.089782 1 True 7
1 LightGBMXT_BAG_L1 0.900085 0.891223 roc_auc 0.329931 0.057655 0.968274 0.329931 0.057655 0.968274 1 True 3
2 LightGBMXT_BAG_L2 0.896987 0.891142 roc_auc 0.902342 0.369916 7.952580 0.243647 0.056751 0.810437 2 True 10
3 WeightedEnsemble_L3 0.895505 0.904069 roc_auc 0.501077 0.203579 6.679074 0.001973 0.000685 0.056311 3 True 12
4 WeightedEnsemble_L2 0.895505 0.904069 roc_auc 0.501568 0.203362 6.657688 0.002464 0.000468 0.034925 2 True 9
5 LightGBM_BAG_L1 0.889478 0.879878 roc_auc 0.235090 0.049692 0.938657 0.235090 0.049692 0.938657 1 True 4
6 RandomForestEntr_BAG_L1 0.886981 0.889863 roc_auc 0.121536 0.096924 0.516171 0.121536 0.096924 0.516171 1 True 6
7 LightGBM_BAG_L2 0.886700 0.870279 roc_auc 0.732673 0.356671 7.886693 0.073979 0.043507 0.744550 2 True 11
8 RandomForestGini_BAG_L1 0.885163 0.887874 roc_auc 0.166933 0.125226 0.866449 0.166933 0.125226 0.866449 1 True 5
9 ExtraTreesGini_BAG_L1 0.879143 0.895789 roc_auc 0.101574 0.096306 0.564707 0.101574 0.096306 0.564707 1 True 8
10 KNeighborsDist_BAG_L1 0.525998 0.536956 roc_auc 0.038055 0.013347 0.003209 0.038055 0.013347 0.003209 1 True 2
11 KNeighborsUnif_BAG_L1 0.514970 0.519604 roc_auc 0.050310 0.015171 0.003808 0.050310 0.015171 0.003808 1 True 1

This command implements the following strategy to maximize accuracy:

  • Specify the argument presets='best_quality', which allows AutoGluon to automatically construct powerful model ensembles based on stacking/bagging, and will greatly improve the resulting predictions if granted sufficient training time. The default value of presets is 'medium_quality', which produces less accurate models but facilitates faster prototyping. With presets, you can flexibly prioritize predictive accuracy vs. training/inference speed. For example, if you care less about predictive performance and want to quickly deploy a basic model, consider using: presets=['good_quality', 'optimize_for_deployment'].

  • Provide the parameter eval_metric to TabularPredictor() if you know what metric will be used to evaluate predictions in your application. Some other non-default metrics you might use include things like: 'f1' (for binary classification), 'roc_auc' (for binary classification), 'log_loss' (for classification), 'mean_absolute_error' (for regression), 'median_absolute_error' (for regression). You can also define your own custom metric function. For more information refer to Adding a custom metric to AutoGluon.

  • Include all your data in train_data and do not provide tuning_data (AutoGluon will split the data more intelligently to fit its needs).

  • Do not specify the hyperparameter_tune_kwargs argument (counterintuitively, hyperparameter tuning is not the best way to spend a limited training time budgets, as model ensembling is often superior). We recommend you only use hyperparameter_tune_kwargs if your goal is to deploy a single model rather than an ensemble.

  • Do not specify the hyperparameters argument (allow AutoGluon to adaptively select which models/hyperparameters to use).

  • Set time_limit to the longest amount of time (in seconds) that you are willing to wait. AutoGluon’s predictive performance improves the longer fit() is allowed to run.

Regression (predicting numeric table columns):

To demonstrate that fit() can also automatically handle regression tasks, we now try to predict the numeric age variable in the same table based on the other features:

age_column = 'age'
train_data[age_column].head()
6118     51
23204    58
29590    40
18116    37
33964    62
Name: age, dtype: int64

We again call fit(), imposing a time-limit this time (in seconds), and also demonstrate a shorthand method to evaluate the resulting model on the test data (which contain labels):

predictor_age = TabularPredictor(label=age_column, path="agModels-predictAge").fit(train_data, time_limit=60)
Hide code cell output
Verbosity: 2 (Standard Logging)
=================== System Info ===================
AutoGluon Version:  1.1.2b20241004
Python Version:     3.10.13
Operating System:   Linux
Platform Machine:   x86_64
Platform Version:   #1 SMP Fri Jun 28 23:44:17 UTC 2024
CPU Count:          8
Memory Avail:       28.06 GB / 30.95 GB (90.7%)
Disk Space Avail:   213.38 GB / 255.99 GB (83.4%)
===================================================
No presets specified! To achieve strong results with AutoGluon, it is recommended to use the available presets. Defaulting to `'medium_quality'`...
	Recommended Presets (For more details refer to https://auto.gluon.ai/stable/tutorials/tabular/tabular-essentials.html#presets):
	presets='best_quality'   : Maximize accuracy. Recommended for most users. Use in competitions and benchmarks. Default time_limit=3600.
	presets='high_quality'   : Strong accuracy with fast inference speed. Default time_limit=3600.
	presets='good_quality'   : Good accuracy with very fast inference speed. Default time_limit=3600.
	presets='medium_quality' : Fast training time, ideal for initial prototyping.
Beginning AutoGluon training ... Time limit = 60s
AutoGluon will save models to "agModels-predictAge"
Train Data Rows:    500
Train Data Columns: 14
Label Column:       age
AutoGluon infers your prediction problem is: 'regression' (because dtype of label-column == int and many unique label-values observed).
Label info (max, min, mean, stddev): (85, 17, 39.652, 13.52393)
If 'regression' is not the correct problem_type, please manually specify the problem_type parameter during Predictor init (You may specify problem_type as one of: ['binary', 'multiclass', 'regression', 'quantile'])
Problem Type:       regression
Preprocessing data ...
Using Feature Generators to preprocess the data ...
Fitting AutoMLPipelineFeatureGenerator...
Available Memory:                    28736.25 MB
Train Data (Original)  Memory Usage: 0.31 MB (0.0% of available memory)
Inferring data type of each feature based on column values. Set feature_metadata_in to manually specify special dtypes of the features.
Stage 1 Generators:
Fitting AsTypeFeatureGenerator...
Note: Converting 2 features to boolean dtype as they only contain 2 unique values.
Stage 2 Generators:
Fitting FillNaFeatureGenerator...
Stage 3 Generators:
Fitting IdentityFeatureGenerator...
Fitting CategoryFeatureGenerator...
Fitting CategoryMemoryMinimizeFeatureGenerator...
Stage 4 Generators:
Fitting DropUniqueFeatureGenerator...
Stage 5 Generators:
Fitting DropDuplicatesFeatureGenerator...
Types of features in original data (raw dtype, special dtypes):
('int', [])    : 5 | ['fnlwgt', 'education-num', 'capital-gain', 'capital-loss', 'hours-per-week']
('object', []) : 9 | ['workclass', 'education', 'marital-status', 'occupation', 'relationship', ...]
Types of features in processed data (raw dtype, special dtypes):
('category', [])  : 7 | ['workclass', 'education', 'marital-status', 'occupation', 'relationship', ...]
('int', [])       : 5 | ['fnlwgt', 'education-num', 'capital-gain', 'capital-loss', 'hours-per-week']
('int', ['bool']) : 2 | ['sex', 'class']
0.1s = Fit runtime
14 features in original data used to generate 14 features in processed data.
Train Data (Processed) Memory Usage: 0.03 MB (0.0% of available memory)
Data preprocessing and feature engineering runtime = 0.09s ...
AutoGluon will gauge predictive performance using evaluation metric: 'root_mean_squared_error'
This metric's sign has been flipped to adhere to being higher_is_better. The metric score can be multiplied by -1 to get the metric value.
To change this, specify the eval_metric parameter of Predictor()
Automatically generating train/validation split with holdout_frac=0.2, Train Rows: 400, Val Rows: 100
User-specified model hyperparameters to be fit:
{
	'NN_TORCH': [{}],
	'GBM': [{'extra_trees': True, 'ag_args': {'name_suffix': 'XT'}}, {}, {'learning_rate': 0.03, 'num_leaves': 128, 'feature_fraction': 0.9, 'min_data_in_leaf': 3, 'ag_args': {'name_suffix': 'Large', 'priority': 0, 'hyperparameter_tune_kwargs': None}}],
	'CAT': [{}],
	'XGB': [{}],
	'FASTAI': [{}],
	'RF': [{'criterion': 'gini', 'ag_args': {'name_suffix': 'Gini', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'entropy', 'ag_args': {'name_suffix': 'Entr', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'squared_error', 'ag_args': {'name_suffix': 'MSE', 'problem_types': ['regression', 'quantile']}}],
	'XT': [{'criterion': 'gini', 'ag_args': {'name_suffix': 'Gini', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'entropy', 'ag_args': {'name_suffix': 'Entr', 'problem_types': ['binary', 'multiclass']}}, {'criterion': 'squared_error', 'ag_args': {'name_suffix': 'MSE', 'problem_types': ['regression', 'quantile']}}],
	'KNN': [{'weights': 'uniform', 'ag_args': {'name_suffix': 'Unif'}}, {'weights': 'distance', 'ag_args': {'name_suffix': 'Dist'}}],
}
Fitting 11 L1 models ...
Fitting model: KNeighborsUnif ... Training model for up to 59.91s of the 59.91s of remaining time.
-15.6869	 = Validation score   (-root_mean_squared_error)
0.0s	 = Training   runtime
0.01s	 = Validation runtime
Fitting model: KNeighborsDist ... Training model for up to 59.89s of the 59.89s of remaining time.
-15.1801	 = Validation score   (-root_mean_squared_error)
0.0s	 = Training   runtime
0.01s	 = Validation runtime
Fitting model: LightGBMXT ... Training model for up to 59.87s of the 59.87s of remaining time.
-11.7092	 = Validation score   (-root_mean_squared_error)
0.35s	 = Training   runtime
0.0s	 = Validation runtime
Fitting model: LightGBM ... Training model for up to 59.5s of the 59.5s of remaining time.
-11.9295	 = Validation score   (-root_mean_squared_error)
0.28s	 = Training   runtime
0.0s	 = Validation runtime
Fitting model: RandomForestMSE ... Training model for up to 59.21s of the 59.21s of remaining time.
-11.6624	 = Validation score   (-root_mean_squared_error)
0.45s	 = Training   runtime
0.05s	 = Validation runtime
Fitting model: CatBoost ... Training model for up to 58.7s of the 58.7s of remaining time.
-11.7993	 = Validation score   (-root_mean_squared_error)
0.63s	 = Training   runtime
0.0s	 = Validation runtime
Fitting model: ExtraTreesMSE ... Training model for up to 58.06s of the 58.06s of remaining time.
-11.3627	 = Validation score   (-root_mean_squared_error)
0.43s	 = Training   runtime
0.05s	 = Validation runtime
Fitting model: NeuralNetFastAI ... Training model for up to 57.57s of the 57.57s of remaining time.
-11.9445	 = Validation score   (-root_mean_squared_error)
0.57s	 = Training   runtime
0.01s	 = Validation runtime
Fitting model: XGBoost ... Training model for up to 56.97s of the 56.97s of remaining time.
-11.5274	 = Validation score   (-root_mean_squared_error)
0.19s	 = Training   runtime
0.01s	 = Validation runtime
Fitting model: NeuralNetTorch ... Training model for up to 56.77s of the 56.77s of remaining time.
/home/ci/opt/venv/lib/python3.10/site-packages/sklearn/compose/_column_transformer.py:1623: FutureWarning: 
The format of the columns of the 'remainder' transformer in ColumnTransformer.transformers_ will change in version 1.7 to match the format of the other transformers.
At the moment the remainder columns are stored as indices (of type int). With the same ColumnTransformer configuration, in the future they will be stored as column names (of type str).
To use the new behavior now and suppress this warning, use ColumnTransformer(force_int_remainder_cols=False).

  warnings.warn(
-11.9806	 = Validation score   (-root_mean_squared_error)
2.26s	 = Training   runtime
0.01s	 = Validation runtime
Fitting model: LightGBMLarge ... Training model for up to 54.49s of the 54.49s of remaining time.
-12.6926	 = Validation score   (-root_mean_squared_error)
0.75s	 = Training   runtime
0.0s	 = Validation runtime
Fitting model: WeightedEnsemble_L2 ... Training model for up to 59.91s of the 53.72s of remaining time.
Ensemble Weights: {'ExtraTreesMSE': 0.48, 'XGBoost': 0.2, 'NeuralNetFastAI': 0.16, 'NeuralNetTorch': 0.16}
-11.1781	 = Validation score   (-root_mean_squared_error)
0.01s	 = Training   runtime
0.0s	 = Validation runtime
AutoGluon training complete, total runtime = 6.3s ... Best model: WeightedEnsemble_L2 | Estimated inference throughput: 1317.9 rows/s (100 batch size)
TabularPredictor saved. To load, use: predictor = TabularPredictor.load("agModels-predictAge")
predictor_age.evaluate(test_data)
{'root_mean_squared_error': -10.474578513117216,
 'mean_squared_error': -109.71679502745684,
 'mean_absolute_error': -8.232829588391127,
 'r2': 0.41354238986968994,
 'pearsonr': 0.6459009870838581,
 'median_absolute_error': -6.8876953125}

Note that we didn’t need to tell AutoGluon this is a regression problem, it automatically inferred this from the data and reported the appropriate performance metric (RMSE by default). To specify a particular evaluation metric other than the default, set the eval_metric parameter of TabularPredictor() and AutoGluon will tailor its models to optimize your metric (e.g. eval_metric = 'mean_absolute_error'). For evaluation metrics where higher values are worse (like RMSE), AutoGluon will flip their sign and print them as negative values during training (as it internally assumes higher values are better). You can even specify a custom metric by following the Custom Metric Tutorial.

We can call leaderboard to see the per-model performance:

predictor_age.leaderboard(test_data)
model score_test score_val eval_metric pred_time_test pred_time_val fit_time pred_time_test_marginal pred_time_val_marginal fit_time_marginal stack_level can_infer fit_order
0 WeightedEnsemble_L2 -10.474579 -11.178103 root_mean_squared_error 0.309356 0.075880 3.464924 0.002930 0.000422 0.010540 2 True 12
1 ExtraTreesMSE -10.655482 -11.362738 root_mean_squared_error 0.100312 0.048586 0.429758 0.100312 0.048586 0.429758 1 True 7
2 RandomForestMSE -10.746175 -11.662354 root_mean_squared_error 0.100471 0.048305 0.448442 0.100471 0.048305 0.448442 1 True 5
3 CatBoost -10.780312 -11.799279 root_mean_squared_error 0.008609 0.004995 0.626561 0.008609 0.004995 0.626561 1 True 6
4 LightGBMXT -10.837373 -11.709228 root_mean_squared_error 0.070463 0.004544 0.352802 0.070463 0.004544 0.352802 1 True 3
5 XGBoost -10.903558 -11.527441 root_mean_squared_error 0.028234 0.005633 0.191016 0.028234 0.005633 0.191016 1 True 9
6 LightGBM -10.972156 -11.929546 root_mean_squared_error 0.020415 0.003610 0.282401 0.020415 0.003610 0.282401 1 True 4
7 NeuralNetTorch -11.141885 -11.980640 root_mean_squared_error 0.043981 0.010846 2.262794 0.043981 0.010846 2.262794 1 True 10
8 NeuralNetFastAI -11.343937 -11.944539 root_mean_squared_error 0.133899 0.010392 0.570816 0.133899 0.010392 0.570816 1 True 8
9 LightGBMLarge -11.832441 -12.692643 root_mean_squared_error 0.033175 0.004275 0.748618 0.033175 0.004275 0.748618 1 True 11
10 KNeighborsUnif -14.902058 -15.686937 root_mean_squared_error 0.024914 0.013803 0.004127 0.024914 0.013803 0.004127 1 True 1
11 KNeighborsDist -15.771259 -15.180149 root_mean_squared_error 0.025707 0.013344 0.003600 0.025707 0.013344 0.003600 1 True 2

Data Formats: AutoGluon can currently operate on data tables already loaded into Python as pandas DataFrames, or those stored in files of CSV format or Parquet format. If your data lives in multiple tables, you will first need to join them into a single table whose rows correspond to statistically independent observations (datapoints) and columns correspond to different features (aka. variables/covariates).

Refer to the TabularPredictor documentation to see all of the available methods/options.

Advanced Usage

For more advanced usage examples of AutoGluon, refer to the In Depth Tutorial

If you are interested in deployment optimization, refer to the Deployment Optimization Tutorial.

For adding custom models to AutoGluon, refer to the Custom Model and Custom Model Advanced tutorials.