file-type

PyTorch文本分类教程:AG_NEWS数据集下载指南

ZIP文件

下载需积分: 50 | 11.25MB | 更新于2025-01-03 | 148 浏览量 | 6 下载量 举报 1 收藏
download 立即下载
AG新闻数据集(AG News Dataset)是由不同新闻类别的文章组成的,这些类别包括世界新闻、体育新闻、娱乐新闻和科技新闻。该数据集被广泛用于机器学习和自然语言处理研究中,特别是在文本分类领域。AG新闻数据集主要由加州大学欧文分校(UC Irvine)提供,并已被整理成适合机器学习模型训练和测试的格式。 数据集文件结构和内容如下: - train.csv:这个文件包含了训练集中的数据。每一行代表一个样本,通常包含两列,第一列是类别标签,第二列是文本内容。例如,类别标签可能是'1'到'4'中的一个数字,分别对应于四个不同的新闻类别。文本内容则是相应的新闻文章内容。 - test.csv:这个文件与train.csv类似,包含了测试集的数据。同样,每一行包含一个类别标签和一个文本内容字段。使用测试集是为了评估模型在未见过的数据上的性能。 - readme.txt:该文件包含对数据集的简要说明,可能包括数据集的来源、数据格式、下载方式等信息。此外,还可能提供有关如何正确使用数据集的指导和建议。 - classes.txt:这个文件列出了数据集中每个类别对应的标签和类别名称。例如,文件中可能包含'1: 世界', '2: 体育', '3: 娱乐', '4: 科技'等条目,用于将类别标签转换为更具可读性的描述。 在使用PyTorch进行文本分类时,TorchText库可以帮助用户方便地处理和预处理文本数据。TorchText是PyTorch生态系统中的一个库,专门用于NLP任务,它提供了一系列工具用于文本的分词(tokenization)、构建词汇表(vocabulary)、编码文本(encoding)等操作。通过使用TorchText,开发者可以轻松地加载AG新闻数据集,并快速开始训练分类模型。 在进行模型训练之前,研究者通常需要进行数据预处理,包括将文本转换为模型可理解的格式,如数字ID序列。TorchText库中的Field类用于定义如何将文本数据转换为模型输入,而BucketIterator类用于创建批次(batch),它允许在训练过程中以固定大小的批次提供数据。这些工具极大简化了数据处理的流程。 在实际应用中,文本分类模型可以应用于新闻推荐系统、垃圾邮件检测、情感分析等多种场景。AG新闻数据集因其包含四个类别且数据量适中,是一个很好的入门级数据集,可以帮助研究人员和开发者在开始NLP项目时建立基本的模型框架。"

相关推荐

filetype
496,835 条来自 AG 新闻语料库 4 大类别超过 2000 个新闻源的新闻文章,数据集仅仅援用了标题和描述字段。每个类别分别拥有 30,000 个训练样本及 1900 个测试样本。 README: AG's News Topic Classification Dataset Version 3, Updated 09/09/2015 ORIGIN AG is a collection of more than 1 million news articles. News articles have been gathered from more than 2000 news sources by ComeToMyHead in more than 1 year of activity. ComeToMyHead is an academic news search engine which has been running since July, 2004. The dataset is provided by the academic comunity for research purposes in data mining (clustering, classification, etc), information retrieval (ranking, search, etc), xml, data compression, data streaming, and any other non-commercial activity. For more information, please refer to the link http://www.di.unipi.it/~gulli/AG_corpus_of_news_articles.html . The AG's news topic classification dataset is constructed by Xiang Zhang ([email protected]) from the dataset above. It is used as a text classification benchmark in the following paper: Xiang Zhang, Junbo Zhao, Yann LeCun. Character-level Convolutional Networks for Text Classification. Advances in Neural Information Processing Systems 28 (NIPS 2015). DESCRIPTION The AG's news topic classification dataset is constructed by choosing 4 largest classes from the original corpus. Each class contains 30,000 training samples and 1,900 testing samples. The total number of training samples is 120,000 and testing 7,600. The file classes.txt contains a list of classes corresponding to each label. The files train.csv and test.csv contain all the training samples as comma-sparated values. There are 3 columns in them, corresponding to class index (1 to 4), title and description. The title and description are escaped using double quotes ("), and any internal double quote is escaped by 2 double quotes (""). New lines are escaped by a backslash followed with an "n" character, that is "\n".