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
