liveBook · Manning

Lightning Flash

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

Lightning Flash is a high-level deep learning framework built on Lightning for rapid prototyping, baselining, fine-tuning, and application development.

Lightning Flash is a high-level deep learning framework built on PyTorch Lightning for rapid prototyping, baselining, fine-tuning, and solving deep learning problems. For tabular work, it abstracts parts of the underlying PyTorch stack while retaining a clear training-oriented API. section 8.1 section 8.7

A practical fit is a tabular classification workflow where categorical fields, numerical fields, and a target are identified up front. Rather than hand-coding a model pipeline, create a data module from separate training, validation, and prediction CSV files, then derive a classifier from that data definition. section 8.4.1 section 8.4.2

The basic workflow is short:

  • Specify the target plus categorical and continuous feature columns. section 8.4.1
  • Build a TabularClassificationData object from train, validation, and prediction CSV files. section 8.4.1
  • Create a TabularClassifier from the data module and train it with flash.Trainer. section 8.4.1

Training an Airbnb NYC classifier

For an Airbnb NYC listing workflow, categorical inputs include neighbourhood group, neighbourhood, and room type; numerical inputs include minimum nights and review-related fields. A TabularClassificationData object supplies those fields and separate CSV splits, while TabularClassifier.from_data and flash.Trainer run a three-epoch GPU-aware training job. section 8.4.1

Lightning Flash favors fast, simple rollouts: the model and training statements are concise, and categorical and continuous columns are identified without explicitly defining a pipeline. Its trade-off is operational fragility in Colab, where a specific installation order and library versions are needed to avoid conflicts. In an untuned comparison, it had the fastest notebook runtime at 14 seconds, while test accuracy was not reported. section 8.4.2 section 8.5

Listing 8.17 Defining a TabularClassificationData
datamodule = TabularClassificationData.from_csv(
    categorical_fields=cat,                                #1
    numerical_fields=cont,                                 #2
    target_fields="target",                                #3
    train_file='../data/train.csv',                        #4
    val_file='../data/valid.csv',                          #5
    predict_file='../data/test.csv',                       #6
    batch_size=64
)

Inspect the data-module definition to see how feature types, target, CSV splits, and batch size form the contract between tabular data and training. section 8.4.1

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

How deep it goes
Walks through installation, imports, feature definitions, CSV data modules, classifier creation, and trainer fitting; defers tuning.
Examples
Uses Airbnb NYC categorical and numerical listing fields with train, validation, and test CSV partitions.
What you can do after
Apply it via Lightning Flash to define tabular data, create a classifier, and train it with flash.Trainer.
How it connects
Connects Lightning Flash with PyTorch Lightning, PyTorch, tabular classification, fastai, TabNet, Keras, and XGBoost.

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.