有没有可能看到pytorchtext.data.TablerDataset?

2024-09-29 19:24:32 发布

您现在位置:Python中文网/ 问答频道 /正文

train, test = data.TabularDataset.splits(path="./data/", train="train.csv",test="test.csv",format="csv",fields=[("Tweet",TEXT), ("Affect Dimension",LABEL)])

我有这个代码,并希望评估,如果加载的数据是正确的,或者如果它使用的实际文本字段等错误的列

如果我的文件中有“Tweet”列作为文本,而“Affect Dimension”列作为类名,那么将它们放在fields部分是否正确?你知道吗

编辑:tablerdataset包含一个示例对象,可以在其中读取数据。读取csv文件时,仅接受“,”作为分隔符。其他一切都会导致数据损坏。你知道吗


Tags: 文件csv数据pathtest文本formatfields
1条回答
网友
1楼 · 发布于 2024-09-29 19:24:32

您可以输入任何字段名,而不管您的文件有什么。另外,我建议不要在字段名中使用空格。你知道吗

所以,把Affect Dimension重命名为Affect_Dimension或者任何对你方便的东西。你知道吗

然后您可以像下面这样遍历不同的字段来检查读取的数据。你知道吗

for i in train.Tweet:
    print i
for i in train.Affect_Dimension:
    print i

for i in test.Tweet:
    print i
for i in test.Affect_Dimension:
    print i

相关问题 更多 >

    热门问题