Supervised learning of tabular data using AutoML


Pipeline of activities in a typical machine learning project involves data preprocessing, exploratory data analysis, feature selection/feature engineering, model selection, hyper parameter tuning, generating model explanation and model selection/evaluation. This is an iterative process and data scientists spend a lot of time going through multiple iterations of this pipeline before they are able to identify the best model. AutoML aims to automates this workflow.

arcgis.learn users will now be able to use AutoML for supervised learning classification or regression problems involving tabular data. The AutoML implementation in arcgis.learn builds upon the implementation from MLJar (

Prepare tabular data

Data can be feature layer, spatially enabled dataframe with/without rasters or just a simple dataframe. The data for AutoML is prepared the same way it is prepared for supervised learning ML Models.

%matplotlib inline

from IPython.display import Image, HTML
import arcgis
from arcgis.gis import GIS
from arcgis.learn import prepare_tabulardata,AutoML
from sklearn.preprocessing import MinMaxScaler,RobustScaler

Here we will be taking a feature layer hosted on ArcGIS Online, convert it to a spatially enabled dataframe and prepare the data using prepare_tabulardata method from arcgis.learn. More details about data preparation for ML Models can be found here

calgary_no_southland_solar ='calgary_no_southland_solar owner:api_data_owner', 'feature layer')[0]
calgary_no_southland_solar_layer = calgary_no_southland_solar.layers[0]
calgary_no_southland_solar_layer_sdf = calgary_no_southland_solar_layer.query().sdf
                                                                           'prcp__mm_d','srad__W_m_','swe__kg_m_', 'tmax__deg',
012017-12-24355827Glenmore Water Treatment Plant109551.003078-114.1005717.20467027648.01108.80000312-10.5-21.01201.2423570.000177{"x": -12701617.407282012, "y": 6621838.159138...
122017-12-25355827Glenmore Water Treatment Plant109551.003078-114.1005713.38523527648.01115.19999712-18.0-29.5402.4777140.000354{"x": -12701617.407282012, "y": 6621838.159138...
232017-12-26355827Glenmore Water Treatment Plant109551.003078-114.1005715.07631627648.00118.40000212-20.0-32.0403.7130710.000530{"x": -12701617.407282012, "y": 6621838.159138...
342017-12-27355827Glenmore Water Treatment Plant109551.003078-114.1005715.61762327648.0096.00000012-18.0-26.5804.9484290.000707{"x": -12701617.407282012, "y": 6621838.159138...
452017-12-28355827Glenmore Water Treatment Plant109551.003078-114.1005712.56151227648.00118.40000212-17.0-28.5406.1837860.000883{"x": -12701617.407282012, "y": 6621838.159138...
X = ['altitude_m', 'wind_speed', 'dayl__s_', 'prcp__mm_d','srad__W_m_','swe__kg_m_','tmax__deg','tmin__deg','vp__Pa_']
preprocessors =  [('altitude_m', 'wind_speed', 'dayl__s_', 'prcp__mm_d','srad__W_m_','swe__kg_m_','tmax__deg',
                   'tmin__deg','vp__Pa_', RobustScaler())]
data = prepare_tabulardata(calgary_no_southland_solar_layer,

Train model using AutoML

from arcgis.learn import AutoML

AutoML class accepts the following paramters:

  • data (Required Paramter): Returned data object from prepare_tabulardata function in the previous step.

  • total_time_limit (Optional parameter): It is the total time in seconds that must be used for AutoML training. Default set is 3600 (1 Hr). At the completion of total_time_limit, the training of AutoML completes and the best model trained until then is used.

  • mode (Optional Parameter): Model can be either Explain. Perform or Compete. Default is Explain.

  • algorithms (Optional Parameter): This parameter takes in list of algorithms as input. The algorithms could be subset of the following: Linear,Decision Tree,Random Forest,Extra Trees,LightGBM,Xgboost,Neural Network.

  • eval_metric (Optional Parameter): The metric to be used to compare models.

AutoML modes

  • Explain : To to be used when you want to explain and understand the data. Uses 75%/25% train/test split. Uses the following models: Baseline, Linear, Decision Tree, Random Forest, XGBoost, Neural Network, and Ensemble. Has full explanations in reports: learning curves, importance plots, and SHAP plots.
  • Perform : To be used when you want to train a model that will be used in real-life use cases. Uses 5-fold CV (Cross-Validation). Uses the following models: Linear, Random Forest, LightGBM, XGBoost,Neural Network, and Ensemble. Has learning curves and importance plots in reports.
  • Compete : To be used for machine learning competitions (maximum performance). Uses 10-fold CV (Cross-Validation). Uses the following models: Decision Tree, Random Forest, Extra Trees, XGBoost, Neural Network, Nearest Neighbors, Ensemble, and Stacking.It has only learning curves in the reports.
AutoML_class_obj = AutoML(data=data)

After creating the AutoML object by passing the data obtained from prepare_tabulardata and using default values for other parameters, now we proceed to train the model using AutoML. This is done by calling the fit method as shown below. New folder will be created and all the models and their varients are saved in that folder.
AutoML directory: AutoML_20
The task is regression with evaluation metric rmse
AutoML will use algorithms: ['Linear', 'Decision Tree', 'Random Forest', 'Extra Trees', 'LightGBM', 'Xgboost', 'Neural Network']
AutoML will ensemble availabe models
AutoML steps: ['simple_algorithms', 'default_algorithms', 'ensemble']
* Step simple_algorithms will try to check up to 2 models
1_DecisionTree rmse 0.050619 trained in 14.53 seconds
2_Linear rmse 0.048289 trained in 6.58 seconds
* Step default_algorithms will try to check up to 5 models
3_Default_LightGBM rmse 0.032221 trained in 9.8 seconds
4_Default_Xgboost rmse 0.033514 trained in 10.93 seconds
5_Default_NeuralNetwork rmse 0.043816 trained in 1.96 seconds
6_Default_RandomForest rmse 0.045735 trained in 3.66 seconds
7_Default_ExtraTrees rmse 0.046594 trained in 3.48 seconds
* Step ensemble will try to check up to 1 model
Ensemble rmse 0.032221 trained in 0.17 seconds
AutoML fit time: 56.1 seconds
AutoML best model: 3_Default_LightGBM
Model has been saved in the path C:\Users\Karthik\Desktop\Base\AutoML\AutoML_20

Once the best model is identified after the completion of fit method, the model is then saved by calling the save method. The transforms and the encoders used on the training data, along with the Esri Model Definition (EMD) file and the dlpk is then saved in the path specified by the user.'<Pass the path>')

We can get the score of the best model, visualize the results on validation dataset and also get predictions on new data using the corresponding methods shown below.


100 rows × 10 columns

As in the case of MLModel and FullyConnectedNetwork, predictions can also be obtained in the form of feature class and rasters.

Additionally it is also possible to generate and view the report of all the models trained by the AutoML, the performance and the hyperparamters used in each of the model variant. The report can be generated using the report method as shown below. The reports, also show the learning curves and feature importance charts for each of the model evaluated during the training.


Reload trained model for prediction

The trained AutoML can be reloaded from the disk to get the predictions on new data. This is done using from_model method. This method takes in the path to the emd file as the input. The best model that was identified using the training phase will automatically be picked up and the prediction can be done on the new data using this model by calling the predict method.

from arcgis.learn import AutoML
AutoML_test_reload=AutoML.from_model(r'<Path to the emd file created after saving the model>')

100 rows × 11 columns

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.