我试图构建一个预测器,告诉我一条推文是否在谈论自然灾害。
使用 Kaggle 数据集。
我有:
text target
15 What's up man? 0
16 I love fruits 0
17 Summer is lovely 0
18 My car is so fast 0
列表还有很多其他内容...
我得到了这个目标的出现次数
0 4342
1 3271
名称:目标,数据类型:int64
这是我的数据块
dls_lm = DataBlock(
blocks=(TextBlock.from_df('text', seq_len=15, is_lm=True), CategoryBlock),
get_x=ColReader('text'), get_y=ColReader('target'), splitter=ColSplitter())
这是我的数据加载器
dls = dls_lm.dataloaders(df2, bs=24)
这是我遇到的错误
KeyError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2897 try:
-> 2898 return self._engine.get_loc(casted_key)
2899 except KeyError as err:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'is_valid'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
5 frames
/usr/local/lib/python3.7/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2898 return self._engine.get_loc(casted_key)
2899 except KeyError as err:
-> 2900 raise KeyError(key) from err
2901
2902 if tolerance is not None:
KeyError: 'is_valid'
如果有人知道我该如何修复它,那真的会对我有很大帮助。谢谢!