liveBook · Manning

Fastai

As explained in Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI

PyTorch with fastai is a deep-learning software stack combining the PyTorch framework with fastai's high-level modeling abstractions.

fastai is a high-level API built on PyTorch that also provides explicit support for tabular data. It is designed to let people apply deep learning to domain problems with few lines of code, while hiding much of the underlying model and training setup. section 8.1 section 8.7

For tabular classification, define the dependent variable plus categorical and continuous feature lists, then create TabularDataLoaders from a data frame. Preprocessing can be declared with FillMissing, Categorify, and Normalize; the data loader packages samples and labels for model use. A tabular_learner can then train with fit_one_cycle and report accuracy. section 8.2.1

Avoiding an unintended regression model

In Airbnb NYC listing-price prediction, a numeric target must be converted to strings for classification. Otherwise, fastai infers continuous targets and selects MSE loss rather than cross-entropy, producing low, stagnant accuracy. Inspect learn.loss_func and a displayed validation batch to diagnose the mismatch before fitting again. section 8.2.1

fastai trades explicit construction for built-in tabular conveniences:

  • It automatically builds the input pipeline from declared transformations and infers model details, so code is more compact than a custom Keras pipeline and layer definition. section 8.2.2
  • It handles categorical and continuous features as first-class tabular inputs and keeps prediction inputs aligned with training transformations. section 8.6
  • Its defaults can introduce subtle, hard-to-debug behavior; going beyond its tabular structures may require deeper API investigation. section 8.2.2 section 8.6
  • It is suited to easy prototyping in Colab, but is less attractive when rapid production deployment is the priority. section 8.5 section 8.6
Table 8.1 Summary of the pros and cons of the Keras and fastai solutions (view table figure)

Keras

fastai

Pro

Model details are transparent.

Large community using the framework means that it’s easy to find solutions to common problems

Framework includes explicit support for tabular data models, which means the code is much more compact.

Framework automatically defines pipeline.

Framework includes convenience functions that make it easy to examine the dataset.

Con

No built-in support for tabular data, which means we need to define custom code to define the pipeline and layers for the model.

Assumptions made by the framework can lead to tricky problems that are hard to debug.

User community is smaller and less involved in deploying production applications than the Keras community, which means it can be harder to find solutions to problems.

Compare the compact, automated fastai approach with the more explicit Keras approach, including their contrasting transparency, tabular support, community, and debugging trade-offs. section 8.2.2

On the untuned Airbnb comparison, fastai achieved slightly better accuracy than the other deep-learning stacks, while Lightning Flash ran faster. Across most tabular datasets, the stated out-of-the-box recommendation remains gradient boosting such as XGBoost for simplicity and overall performance. section 8.5

How Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI covers it

How deep it goes
Walks through dataset declarations, preprocessing, data loaders, training, loss inspection, and model summaries without exposing layer construction.
Examples
Uses Airbnb NYC listing-price classification, target-string conversion, loss-function output, validation batches, and accuracy comparisons.
What it assumes
Assumes a tabular dataset and Python notebook setup while supplying fastai imports and feature-role declarations.
What you can do after
Apply it via fastai to prepare tabular data, train a classifier, inspect its loss function, and identify target-type mistakes.
How it connects
Connects PyTorch, tabular data, TabularDataLoaders, Keras, TensorFlow, XGBoost, TabNet, and Lightning Flash.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI. The section links point to the parts of the book it draws on.