0

我正在努力编写正确的方法:get_items()for DataBlock. 这是我正在关注的教程。

question_label_path = 'text_label.csv'

def getTextLabels(arg):
    df = pd.read_csv(arg)
    return df[['text', 'label']].to_numpy()
    

textBlock = (TextBlock.from_df(text_cols = ['text'], vocab=dls_lm.vocab),CategoryBlock)

dls_clas = DataBlock(
    blocks=textBlock,
    get_x = ColReader(cols='text'),
    get_y = ColReader(cols = "label"),
    get_items= getTextLabels,
    splitter = TrainTestSplitter(test_size = 0.2, random_state = 21, stratify=["label"])
).dataloaders(question_label_path, bs=64)

由于我的工作性质,我无法提供完整的数据集,但它看起来像这样: 在此处输入图像描述

这是错误消息: 在此处输入图像描述

4

0 回答 0