Dataset:fetch_20newsgroups(20类新闻文本)数据集的简介、安装、使用方法之详细攻略

简介: Dataset:fetch_20newsgroups(20类新闻文本)数据集的简介、安装、使用方法之详细攻略

fetch_20newsgroups(20类新闻文本)数据集的简介


       20 newsgroups数据集18000多篇新闻文章,一共涉及到20种话题,所以称作20newsgroups text dataset,分为两部分:训练集和测试集,通常用来做文本分类,均匀分为20个不同主题的新闻组集合。20newsgroups数据集是被用于文本分类、文本挖据和信息检索研究的国际标准数据集之一。一些新闻组的主题特别相似(e.g. comp.sys.ibm.pc.hardware/ comp.sys.mac.hardware),还有一些却完全不相关 (e.g misc.forsale /soc.religion.christian)。



1、数据集信息


数据集形状 (18846,)


   =================   ==========

   Classes                     20

   Samples total            18846

   Dimensionality               1

   Features                  text

   =================   ==========




2、数据集标签20类别


['alt.atheism', 'comp.graphics', 'comp.os.ms-windows.misc', 'comp.sys.ibm.pc.hardware', 'comp.sys.mac.hardware', 'comp.windows.x', 'misc.forsale', 'rec.autos', 'rec.motorcycles', 'rec.sport.baseball', 'rec.sport.hockey', 'sci.crypt', 'sci.electronics', 'sci.med', 'sci.space', 'soc.religion.christian', 'talk.politics.guns', 'talk.politics.mideast', 'talk.politics.misc', 'talk.religion.misc']




3、数据集前三篇文章


["From: Mamatha Devineni Ratnam <mr47+@andrew.cmu.edu>\nSubject: Pens fans reactions\nOrganization: Post Office, Carnegie Mellon, Pittsburgh, PA\nLines: 12\nNNTP-Posting-Host: po4.andrew.cmu.edu\n\n\n\nI am sure some bashers of Pens fans are pretty confused about the lack\nof any kind of posts about the recent Pens massacre of the Devils. Actually,\nI am  bit puzzled too and a bit relieved. However, I am going to put an end\nto non-PIttsburghers' relief with a bit of praise for the Pens. Man, they\nare killing those Devils worse than I thought. Jagr just showed you why\nhe is much better than his regular season stats. He is also a lot\nfo fun to watch in the playoffs. Bowman should let JAgr have a lot of\nfun in the next couple of games since the Pens are going to beat the pulp out of Jersey anyway. I was very disappointed not to see the Islanders lose the final\nregular season game.          PENS RULE!!!\n\n", 'From: mblawson@midway.ecn.uoknor.edu (Matthew B Lawson)\nSubject: Which high-performance VLB video card?\nSummary: Seek recommendations for VLB video card\nNntp-Posting-Host: midway.ecn.uoknor.edu\nOrganization: Engineering Computer Network, University of Oklahoma, Norman, OK, USA\nKeywords: orchid, stealth, vlb\nLines: 21\n\n  My brother is in the market for a high-performance video card that supports\nVESA local bus with 1-2MB RAM.  Does anyone have suggestions/ideas on:\n\n  - Diamond Stealth Pro Local Bus\n\n  - Orchid Farenheit 1280\n\n  - ATI Graphics Ultra Pro\n\n  - Any other high-performance VLB card\n\n\nPlease post or email.  Thank you!\n\n  - Matt\n\n-- \n    |  Matthew B. Lawson <------------> (mblawson@essex.ecn.uoknor.edu)  |   \n  --+-- "Now I, Nebuchadnezzar, praise and exalt and glorify the King  --+-- \n    |   of heaven, because everything he does is right and all his ways  |   \n    |   are just." - Nebuchadnezzar, king of Babylon, 562 B.C.           |   \n']




fetch_20newsgroups(20类新闻文本)数据集的安装


fetch_20newsgroups(data_home=None, # 文件下载的路径

                  subset='train', # 加载那一部分数据集 train/test

                  categories=None, # 选取哪一类数据集[类别列表],默认20类

                  shuffle=True,  # 将数据集随机排序

                  random_state=42, # 随机数生成器

                  remove=(), # ('headers','footers','quotes') 去除部分文本

                  download_if_missing=True # 如果没有下载过,重新下载

                  )

news = fetch_20newsgroups(subset='all')



fetch_20newsgroups(20类新闻文本)数据集的使用方法


ML之LoR:利用pipeline对fetch_20newsgroups数据集(文本抽取TfidfVectorizer)采用SVC算法(GSCV)实现多分类

https://yunyaniu.blog.csdn.net/article/details/108284947

ML之NB:利用朴素贝叶斯NB算法(CountVectorizer+不去除停用词)对fetch_20newsgroups数据集(20类新闻文本)进行分类预测、评估

https://yunyaniu.blog.csdn.net/article/details/88082855


相关文章
|
开发工具 git
从 github 执行 git clone 一个大的项目时提示 error: RPC failed
目前克隆一个比较大的项目,出现RPC failed的错误 Cloning into 'bigfiles'... remote: Counting objects: 190, done. remote: Compressing objects: 100% (157/157), done.
4323 0
|
10月前
|
JSON 数据挖掘 API
lazada商品详情接口 (lazada API系列)
Lazada 是东南亚知名电商平台,提供海量商品资源。通过其商品详情接口,开发者和商家可获取商品标题、价格、库存、描述、图片、用户评价等详细信息,助力市场竞争分析、商品优化及库存管理。接口采用 HTTP GET 请求,返回 JSON 格式的响应数据,支持 Python 等语言调用。应用场景包括竞品分析、价格趋势研究、用户评价分析及电商应用开发,为企业决策和用户体验提升提供有力支持。
383 21
|
机器学习/深度学习 人工智能 自然语言处理
深度学习中的优化算法及其应用
【10月更文挑战第8天】 本文将探讨深度学习中常用的优化算法,包括梯度下降法、Adam和RMSProp等,介绍这些算法的基本原理与应用场景。通过实例分析,帮助读者更好地理解和应用这些优化算法,提高深度学习模型的训练效率与性能。
921 63
|
12月前
|
编解码 人工智能 开发框架
《鸿蒙HarmonyOS应用开发从入门到精通(第2版)》学习笔记——HarmonyOS技术理念
HarmonyOS在万物智联时代提出了三大技术理念:一次开发,多端部署;可分可合,自由流转;统一生态,原生智能。通过多端开发环境、多端开发能力和多端分发机制,HarmonyOS显著降低了开发成本,提升了开发效率。开发者只需一套工程即可实现多设备应用的高效开发与部署。元服务作为轻量化程序实体,支持跨设备无缝流转,提供便捷服务。同时,HarmonyOS内置强大的AI能力,助力开发者快速实现应用智能化。
689 16
|
安全 搜索推荐 数据安全/隐私保护
定制你的清爽Mac版Edge浏览器
【10月更文挑战第5天】本文介绍了如何定制Mac版Edge浏览器以实现清爽高效的操作体验。内容包括:选择主题以适应不同环境,自定义工具栏以保持界面简洁;启用隐私浏览模式及调整隐私设置来保护个人信息;通过更新浏览器和开启安全筛选器来加强安全性;安装扩展程序以增强功能,并设置启动选项和快捷方式以便于操作。通过这些方法,你可以根据个人需求打造个性化的浏览器环境。
513 5
|
机器学习/深度学习 资源调度 自然语言处理
循环神经网络RNN完全解析:从基础理论到PyTorch实战1
循环神经网络RNN完全解析:从基础理论到PyTorch实战
2302 0
ConnectionResetError: [Errno 104] Connection reset by peer|4-16
ConnectionResetError: [Errno 104] Connection reset by peer|4-16
|
存储 安全 区块链
智能合约开发中13种最常见的漏洞
智能合约开发中13种最常见的漏洞
1767 5
|
存储 Linux 数据安全/隐私保护
如何在Linux搭建MinIO服务并实现无公网ip远程访问内网管理界面
如何在Linux搭建MinIO服务并实现无公网ip远程访问内网管理界面
|
机器学习/深度学习 开发工具 git
开发专题 | 1 :下载 huggingface 上模型的正确姿势
本文主要介绍如何以正确的方式下载 huggingface 上的模型

热门文章

最新文章