Guides

Tabular data: gradient boosting vs. MLP, and when to use which

For a table of rows and columns, gradient-boosted trees are usually the stronger first model, and a multi-layer perceptron (MLP) is the more flexible one. Which one wins depends on your data, so the useful question is how to find out quickly and fairly.

The short answer

Start with gradient boosting. It needs little preparation and little tuning, copes with features on very different scales and finds interactions between columns by itself. Try an MLP next to it when the table is large, when the relationship is smooth, when you need several outputs at once, or when the table is only one of the inputs, next to an image or a text. Then compare both on the same held-out rows.

How each model sees a table

Gradient boosting builds decision trees one after the other, each correcting the errors of the trees before it. A tree splits on one column at a time (“rainfall above 41 mm”), so the scale of a column does not matter, a few extreme values do no harm, and a step in the data is easy to represent. Outside the range of the training data, a tree predicts the value of its outermost leaf: it does not extrapolate.

An MLP multiplies the standardised features by weights, adds them up and passes the result through non-linear activations, layer after layer. It represents smooth relationships well and learns from all columns at once, but it needs numbers on comparable scales, enough rows to fit its weights, and settings such as the learning rate and the number of epochs.

Side by side

Gradient boosting and an MLP on tabular data, in Brick DNN
QuestionGradient boostingMLP
PreparationFill in missing values and encode categories (in the Data tab); no scaling neededThe same; features are standardised by the training (mean 0, standard deviation 1)
RowsUp to 1,000,000 training rows, time about linear in the rowsAny number, in batches; profits from many rows
Settings to tuneLearning rate, leaves per tree, rows per leaf; good defaultsLayer sizes, learning rate, batch size, epochs, dropout
TrainingFitted once, in seconds to minutesEpoch by epoch, with curves and early stopping
Rare classesclass_weight balancedWeighted cross-entropy or focal loss
Several targets, other inputsOne targetSeveral outputs; can be one branch of a larger network
Exportscikit-learn script and fitted pipeline (.joblib)PyTorch script and weights (.pt)

Compare them on the same rows

A comparison is only fair when both models learn from the same training rows and are judged on the same rows they never saw. In Brick DNN that is what a prepared dataset gives you:

  1. Prepare the table once

    Import the file in the Data tab, choose the target, and add steps for missing values, outliers, categories and dates. Every row is assigned to training, validation or test once, and steps that learn values (a median, a scaling) learn them from the training rows only.

  2. Create the training dataset

    Create training dataset saves the prepared table with its split. Both models will use this split instead of a random one of their own.

  3. Train gradient boosting

    Open the gradient boosting example (or its regression brick), choose the dataset and train. The Input adapts to the number of features. A hyperparameter search with cross-validation on the training rows tunes the trees without touching the validation rows.

  4. Train an MLP

    Open the tabular MLP example, or start from an empty canvas: choosing the dataset there starts a small network for it (Input → Linear → ReLU → Linear). Turn on early stopping and train.

  5. Compare the test numbers

    Compare on the test rows, not on the validation rows that picked the epoch or the trial: balanced accuracy, macro F1 or PR AUC for classes, RMSE and R² for a number. The History tab keeps both runs, each with the exact network that was trained.

A preparation in the Data tab: on the left the steps for missing values, outliers and categories with what each did, on the right the prepared table with a small distribution chart in each column header.
One preparation, one split, for every model you compare.

Tune both, briefly

Untuned defaults favour gradient boosting, because its defaults are good for most tables. Give the MLP a short random search over learning rate and batch size; give the trees one over the learning rate, the leaves per tree and the rows per leaf. Rank both searches by the metric you will report, not by the loss.

The trials of a random search for gradient boosting: learning rate, depth, rows per leaf and class weights of each trial with its cross-validated loss, accuracy and PR AUC; the best trial is highlighted.
A search over the parameters of gradient boosting, ranked by PR AUC.

Which one, then?

  • Gradient boosting when the table is small or medium, has columns of mixed scales and meaning, contains thresholds and steps, or when you need a strong result quickly.
  • An MLP when the table is large and the relationship smooth, when it must predict several targets at once, when it has to extrapolate a little beyond the training range, or when the table is one input of a network that also sees images or text (see the multi-input example).
  • Both: a hybrid network lets an MLP learn features for gradient boosting, and a voting or stacking ensemble combines several classical models.

Look at what the winner learned

Explain the model under a finished run works for both kinds: permutation importance shows how much the validation score drops when one column is shuffled, and Shapley values show how each feature pushed one prediction. If the two models rely on very different columns, look at the data again before trusting either.

Permutation importance of a gradient boosting model: how much the validation accuracy drops when one feature is shuffled, most for rainfall, then temperature and nitrogen.
Permutation importance: which columns the model really uses.

Examples to start from

  • Gradient boosting classifier

    Gradient-boosted trees classify rows of 30 features; balanced class weights for rare classes.

    scikit-learn · HistGradientBoostingClassifier

  • Tabular regression

    Predicts one number from 8 numeric features; the script trains on a CSV file.

    PyTorch · 2,817 parameters

  • MLP features for gradient boosting

    An MLP learns 32 features, then gradient-boosted trees are fitted on them and predict the class.

    PyTorch + scikit-learn · 2,656 parameters

More guides

Open the editor