1

我在使用 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'

快泰 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

我尝试了表格数据概述页面中的代码,它可以工作,但是当我在自己的数据上尝试时,出现了上述问题。

4

0 回答 0