我在使用fastai表格数据时遇到问题,因此我尝试做最简单的事情就是拟合多项式。但是,当我创建数据束时,出现错误
~/miniconda3/lib/python3.7/site-packages/fastai/tabular/data.py in get(self, o)
119
120 def get(self, o):
--> 121 codes = [] if self.codes is None else self.codes[o]
122 conts = [] if self.conts is None else self.conts[o]
123 return self._item_cls(codes, conts, self.classes, self.col_names)
AttributeError: 'TabularList' object has no attribute 'codes'
fastai版本1.0.27
以下是导致错误的代码:
from fastai import *
from fastai.tabular import *
import os
# generate some polynomial to test the functions out
x = np.arange(0, 1000)
y = x^2 + 1
# some fastai variables
path = os.getcwd()
df = pd.DataFrame({'x': x, 'y': y})
dep_var = 'y'
cat_names = []
procs = [Normalize]
valid_idx = range(1,1000)
# get the data bunch
data = TabularDataBunch.from_df(path, df, dep_var, valid_idx=valid_idx, procs=procs) # this line causes the error above
我从表格数据的overview页尝试了代码,它可以工作,但是当我对自己的数据尝试时,出现了上述问题。