liveBook · Manning

TabularDataLoaders

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

TabularDataLoaders is a fastai data-loading abstraction that packages tabular samples, labels, preprocessing, and data splits for model training.

TabularDataLoaders packages tabular samples and labels with the column roles, preprocessing steps, validation split, and batch size needed for fastai training. section 8.2.1

Configure it by specifying:

  • The dependent variable, categorical columns, and continuous columns. section 8.2.1
  • Preprocessors such as FillMissing, Categorify, and Normalize. section 8.2.1
  • A validation index and batch size for training. section 8.2.1

Airbnb listing classification

For the Airbnb NYC listing problem, define target, neighbourhood, room type, and numeric listing columns, then create the loaders from a dataframe. Convert the target to strings before training; otherwise fastai can select mean squared error instead of cross-entropy. section 8.2.1

Listing 8.5 Defining the TabularDataLoaders object
path = '.'                                                #1
procs = [FillMissing,Categorify, Normalize]               #2
dls = TabularDataLoaders.from_df(dtrain,                  #3
                                 path,
                                 procs= procs,            #4
                                 cat_names= cat,          #5
                                 cont_names = cont,       #6
                                 y_names = dep_var,       #7
                                 valid_idx=\
list(range((merged_data.shape[0]-10000),
merged_data.shape[0])),                                   #8
                                 bs=32)                   #9

Inspect the complete TabularDataLoaders configuration, including preprocessing, column names, validation indices, and batch size. section 8.2.1

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

How deep it goes
Explains configuration, preprocessing, validation splitting, batching, and target typing, but stops short of loader internals.
Examples
Uses Airbnb NYC listings, named neighbourhood and room-type columns, dataframe loaders, sample batches, and target-type debugging.
What it assumes
Assumes a dataframe and identified target, categorical, continuous, and validation columns; teaches the loader configuration explicitly.
What you can do after
Operate/configure fastai loaders for tabular classification and diagnose incorrect loss selection caused by numeric targets.
How it connects
Connects categorical columns, continuous columns, preprocessing, validation data, batch size, and loss functions.

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.