Load_learner Error when trying to load a tabularLearner with no category columns

I encounter this issue when doing my research. My fastai version is 1.0.42. I replicate a similar scenario using the code from https://docs.fast.ai/tabular.data.html

import fastai
from fastai.tabular import *

path = untar_data(URLs.ADULT_SAMPLE)
df = pd.read_csv(path/'adult.csv')

# captical-loss is a numerical columns
df = df[["salary", "capital-loss"]]

dep_var = 'salary'
procs = [FillMissing, Categorify, Normalize]
val_idx = range(len(df) - 2000, len(df))

data = TabularDataBunch.from_df(path, df, dep_var, valid_idx=val_idx, procs=procs)
learn = tabular_learner(data, layers=[200,100], metrics=accuracy)


the load_learner throws an error as:

Exception reporting mode: Plain
Traceback (most recent call last):

  File "<ipython-input-35-524bf55a7a03>", line 2, in <module>
    loaded_learn = load_learner(path)

  File "/home/aurora/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/basic_train.py", line 471, in load_learner
    src = LabelLists.load_state(path, state.pop('data'))

  File "/home/aurora/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/data_block.py", line 507, in load_state
    train_ds = LabelList.load_state(path, state)

  File "/home/aurora/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/data_block.py", line 605, in load_state
    res = cls(x, y, tfms=state['tfms'], tfm_y=state['tfm_y'], **state['tfmargs']).process()

  File "/home/aurora/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/data_block.py", line 627, in process

  File "/home/aurora/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/data_block.py", line 68, in process
    for p in self.processor: p.process(self)

  File "/home/aurora/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/tabular/data.py", line 59, in process
    ds.classes,ds.cat_names,ds.cont_names = self.classes,self.cat_names,self.cont_names

AttributeError: 'TabularProcessor' object has no attribute 'classes'

I didn’t find this issue when using the whole Adult_sample dataset.

One different between these two is in the classes and y.classes attribution:

Using the full dataset

Using only “salary”, “capital-loss” columns

This is my first pose :no_mouth: I hope I am not bothering anyone.

1 Like

You’re not bothering anyone and this is indeed a bug so I’m glad you told us! I just pushed a fix in master that will be available in v1.0.43 (or right now if you use a dev install).


Hello sgugger,
I hope all is well. I am receiving the same AtrributeError. My current verison : 1.0.48.
My next step is to run the dev install to see if that will fix the issue.
Any advice?