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
