.. _sec_faq: FAQ === How can I get the most accurate predictions? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See `“Maximizing predictive performance” in the Quick Start Tutorial `__. Can I run AutoGluon Tabular on Mac/Windows? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Yes! Can I use GPUs for model training? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Yes! Most of the models used by AutoGluon support GPU training, including LightGBM, CatBoost, XGBoost, MXNet Neural Network, and FastAI Neural Network. To enable GPU training, specify in `predictor.fit <../../api/autogluon.predictor.html#autogluon.tabular.TabularPredictor.fit>`__ the argument ``num_gpus=SOME_VALUE``. This will enable GPU training for all models that support it. Multi-GPU training is still experimental. For most of these models, CUDA will have to be installed and some models may need special installations such as LightGBM and MXNet to be compatible with GPU training. Refer to `installation instructions <../../install.html>`__ for more details. What machine is best for running AutoGluon Tabular? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ As an open-source library, AutoGluon can be run on any machine including your laptop. Currently it is not necessary to use a GPU to train TabularPredictor so CPU machines are fine (in contrast, MultiModalPredictor require GPUs). Most Tabular issues arise due to lack of memory, so we recommend running on a machine with as much memory as possible. For example if using AWS instances for Tabular: we recommend `M5 instances `__, where a **m5.24xlarge** machine should be able to handle most datasets. How can I resolve memory issues? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See `“If you encounter memory issues” in the In Depth Tutorial `__. How can I resolve disk space issues? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See `“If you encounter disk space issues” in the In Depth Tutorial `__. How can I reduce the time required for training? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Specify the ``time_limit`` argument in `predictor.fit <../../api/autogluon.predictor.html#autogluon.tabular.TabularPredictor.fit>`__ to the number of seconds you are willing to wait (longer time limits generally result in superior predictive performance). You may also try other settings of the ``presets`` argument in `predictor.fit <../../api/autogluon.predictor.html#autogluon.tabular.TabularPredictor.fit>`__, and can also subsample your data for a quick trial run via ``train_data.sample(n=SUBSAMPLE_SIZE)``. If a particular type of model is taking much longer to train on your data than the other types of models, you can tell AutoGluon not to train any models of this particular type by specifying its short-name in the ``excluded_model_types`` argument of ``fit()``. Since many of the strategies to reduce memory usage also reduce training times, also check out: `“If you encounter memory issues” in the In Depth Tutorial `__. How can I reduce the time required for prediction? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See `“Accelerating inference” in the In Depth Tutorial `__. How does AutoGluon Tabular work internally? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Details are provided in the following paper: `AutoGluon-Tabular: Robust and Accurate AutoML for Structured Data `__. *Arxiv*, 2020. How can I view more detailed logs of what is happening during fit? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Specify the argument ``verbosity = 4`` in ``fit()``. What model is AutoGluon using for prediction? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See `“Prediction options” in the In Depth Tutorial `__. Which classes do predicted probabilities correspond to? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This should become obvious if you look at the pandas DataFrame column names from the prediction probability output: :: predictor.predict_proba(test_data) For binary and multiclass classification: :: predictor.class_labels is a list of classes whose order corresponds to columns of ``predict_proba(as_pandas=False)`` output when it is a Numpy array. You can see which class AutoGluon treats as the positive class in binary classification via: :: predictor.positive_class The positive class can also be retrieved via ``predictor.class_labels[-1]``. The output of ``predict_proba(as_multiclass=False)`` for binary classification is the probability of the positive class. How can I use AutoGluon for interpretability? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See `“Interpretability (feature importance)” in the In Depth Tutorial `__, which allows you to quantify how much each feature contributes to AutoGluon’s predictive accuracy. Additionally, you can explain particular AutoGluon predictions using `Shapely values `__. Notebooks demonstrating this are provided at: https://github.com/autogluon/autogluon/tree/master/examples/tabular/interpret. We recommend starting with the notebook “SHAP with AutoGluon-Tabular” contained in this folder, which demonstrates handling of multiclass classification tasks and data with categorical features. How can I perform inference on a file that won’t fit in memory? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Tabular Dataset API works with pandas DataFrames, which supports chunking data into sizes that fit in memory. Here’s an example of one such chunk-based inference: .. code:: python from autogluon.tabular import TabularDataset, TabularPredictor import pandas as pd import requests train_data = TabularDataset('https://autogluon.s3.amazonaws.com/datasets/Inc/train.csv') predictor = TabularPredictor(label='class').fit(train_data.sample(n=100, random_state=0), hyperparameters={'GBM': {}}) # Get the test dataset, if you are working with local data then omit the next two lines r = requests.get('https://autogluon.s3.amazonaws.com/datasets/Inc/test.csv', allow_redirects=True) open('test.csv', 'wb').write(r.content) reader = pd.read_csv('test.csv', chunksize=1024) y_pred = [] y_true = [] for df_chunk in reader: y_pred.append(predictor.predict(df_chunk)) y_true.append(df_chunk['class']) y_pred = pd.concat(y_pred, axis=0, ignore_index=True) y_true = pd.concat(y_true, axis=0, ignore_index=True) predictor.evaluate_predictions(y_true=y_true, y_pred=y_pred) .. parsed-literal:: :class: output No path specified. Models will be saved in: "AutogluonModels/ag-20230306_115920/" Beginning AutoGluon training ... AutoGluon will save models to "AutogluonModels/ag-20230306_115920/" AutoGluon Version: 0.7.0b20230306 Python Version: 3.8.13 Operating System: Linux Platform Machine: x86_64 Platform Version: #1 SMP Tue Nov 30 00:17:50 UTC 2021 Train Data Rows: 100 Train Data Columns: 14 Label Column: class Preprocessing data ... 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']) 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: 31503.01 MB Train Data (Original) Memory Usage: 0.06 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... 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.01 MB (0.0% of available memory) Data preprocessing and feature engineering runtime = 0.08s ... 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: 80, Val Rows: 20 Fitting 1 L1 models ... Fitting model: LightGBM ... 0.8 = Validation score (accuracy) 0.83s = Training runtime 0.0s = Validation runtime Fitting model: WeightedEnsemble_L2 ... 0.8 = Validation score (accuracy) 0.0s = Training runtime 0.0s = Validation runtime AutoGluon training complete, total runtime = 1.54s ... Best model: "WeightedEnsemble_L2" TabularPredictor saved. To load, use: predictor = TabularPredictor.load("AutogluonModels/ag-20230306_115920/") Evaluation: accuracy on test data: 0.7628211690039922 Evaluations on test data: { "accuracy": 0.7628211690039922, "balanced_accuracy": 0.515967102411626, "mcc": 0.09302340489249436, "f1": 0.08455156064796523, "precision": 0.5023474178403756, "recall": 0.04616048317515099 } .. parsed-literal:: :class: output {'accuracy': 0.7628211690039922, 'balanced_accuracy': 0.515967102411626, 'mcc': 0.09302340489249436, 'f1': 0.08455156064796523, 'precision': 0.5023474178403756, 'recall': 0.04616048317515099} Here we split the test data into chunks of up to 1024 rows each, but you may select a larger size as long as it fits into your system’s memory. `Further Reading `__ How can I skip some particular models? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To avoid training certain models, specify these in the ``excluded_model_types`` argument. For example, here’s how to call ``fit()`` without training K Nearest Neighbor (KNN), Random Forest (RF), or ExtraTrees (XT) models: :: task.fit(..., excluded_model_types=['KNN','RF','XT']) How can I add my own custom model to the set of models that AutoGluon trains, tunes, and ensembles? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To learn how to add your own custom models to the set that AutoGluon trains, tunes, and ensembles, review :ref:`sec_tabularcustommodel`. How can I reproduce the results of model XYZ without using AutoGluon? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Exactly reproducing the results of AutoGluon models without using AutoGluon can be challenging (Ex: Trying to replicate the results of AutoGluon’s LightGBM without depending on AutoGluon). AutoGluon uses a variety of techniques not present in the model frameworks it builds upon such as data preprocessing, edge case handling, custom early stopping, and custom architectures. These are all used to enhance the performance and simplify usage beyond what exists in the original model framework (such as LightGBM, XGBoost, FastAI, etc.). This is a core benefit of AutoML frameworks and is inherently complicated to replicate (you would have to reimplement much of what AutoGluon does behind the scenes). If you still wish to try to replicate results, the logic can be derived from the source code. Why was XYZ design decision chosen? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Usually the answer boils down to “because it performed better on average than the alternatives we tested across a wide variety of benchmark datasets” and/or “because it is simple and easy to implement while likely performing similarly to more complex methods” and/or “because it worked well enough and we haven’t investigated further options”. AutoML is inherently an empirically oriented field rather than a theoretical one. This is because theoretically explaining why the various AutoML components work together better than numerous alternatives in practice is not particularly feasible nor generalizable. How can I add my own custom data preprocessing or feature engineering? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Note that the ``TabularDataset`` object is essentially a `pandas DataFrame `__ and you can transform your training data however you wish before calling ``fit()``. Note that any transformations you perform yourself must also be applied to all future test data before calling ``predict()``, and AutoGluon will still perform its default processing on your transformed data inside ``fit()``. To solely use custom data preprocessing and automatically apply your custom transformations to both the train data and all future data encountered during inference, you should instead create a custom FeatureGenerator. Follow this example in the source code: `examples/tabular/example_custom_feature_generator.py `__ How can I differently weight the importance of training examples? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can specify the ``sample_weight`` and ``weight_evaluation`` `arguments <../../api/autogluon.predictor.html#autogluon.tabular.TabularPredictor>`__ when initializing a ``TabularPredictor``. How does missing value imputation work in AutoGluon? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AutoGluon does not perform generic missing value imputation, instead it sends the missing values to each model, and each model has different custom handling of missing values. This improves model diversity and thus the final strength of the ensemble. Refer to the model source code to learn how missing values are handled. I’m receiving C++ warning spam during training or inference ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: Warning message: [W ParallelNative.cpp:206] Warning: Cannot set number of intraop threads after parallel work has started or after set_num_threads call when using native parallel backend (function set_num_threads) This can happen from downstream PyTorch dependencies (OpenMP) when using a specific environment. If you are using PyTorch 1.7, Mac OS X, Python 3.6/3.7, and using the PyTorch DataLoader, then you may get this warning spam. We have only seen this occur with the TabTransformer model. Reference open `torch issue `__. The recommended workaround from the torch issue to suppress this warning is to set an environment variable used in OpenMP. This has been tested on Torch 1.7, Python 3.6, and Mac OS X. :: export OMP_NUM_THREADS=1 How to limit the number of cores AutoGluon will use ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Although it is generally recommended to let AutoGluon to use all the cores, you can limit it by setting the ``num_cpus``: :: predictor = TabularPredictor(...).fit(..., num_cpus = NUM_CORES_YOU_WANT) You can also limit the number of cores used by a specific model: :: # We use 1 core for CatBoost model, 4 cores for XGBoost model, and all cores for lightGBM model here. predictor = TabularPredictor(...).fit(..., hyperparameters= {'CAT': {'ag_args_fit': {'num_cpus': 1}}, 'XGB': {'ag_args_fit': {'num_cpus': 4}}, 'GBM': {}},) My custom metric is raising ``_pickle.PicklingError: Can't pickle`` errors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See `“Ensuring Metric is Serializable” in Custom Metric Tutorial `__. I know AutoGluon uses ray underneath. What’s the best practice for me? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It is generally recommended to not have your custom usage of ray resources, i.e. init ray cluster, along with AutoGluon in a same script. Ray does not support multiple runtimes in a same script, hence unexpected behaviors could happen. No space left error on SageMaker Notebook ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you are using AutoGluon on SageMaker Notebook, it is likely that you will encounter such error: ``OSError: [Errno 28] No space left on device``. This is because the default disk size of a SageMaker Notebook instance is 5 GiB regardless of the type. AutoGluon training on some large datasets could end up with artifacts that’s larger than 5GiB. To address it, either cleanup your workspace, or 1) shutdown your Notebook instance 2) choose your Notebook instance 3) update the ``Volume size in GB`` field under ``Edit`` Issues not addressed here ~~~~~~~~~~~~~~~~~~~~~~~~~ First search if your issue is addressed in the `tutorials `__, `examples `__, `documentation <../../api/autogluon.predictor.html>`__, or `Github issues `__ (search both Closed and Open issues). If it is not there, please open a `new Github Issue `__ and clearly state your issue. If you have a bug, please include: your code (call ``fit(..., verbosity=4)`` which will print more details), the output printed during the code execution, and information about your operating system, Python version, and installed packages (output of ``pip freeze``).