数据分析-学术前沿趋势分析

  • 1 简介
    • 1.1 问题背景
    • 1.2 数据说明
  • 2 数据介绍
  • 3 具体代码实现
    • 3.1 导入相关package并读取原始数据
    • 3.2 数据预处理
    • 3.3 数据分析及可视化
  • 总结

1 简介

该博客将对于学术前沿论文做一些pandas操作。

1.1 问题背景

本篇博客是对于kaggle里面一个比赛为例子,比赛地址:https://www.kaggle.com/Cornell-University/arxiv,对使用公开的arxiv论文完成一些数据分析操作,实现具体的可视化分析。这篇博客统计2019年全年,计算机各个方向的论文数量。

1.2 数据说明

arXiv 是重要的学术公开网站,也是搜索、浏览和下载学术论文的重要工具。arXiv论文涵盖的范围非常广,涉及物理学的庞大分支和计算机科学的众多子学科,如数学、统计学、电气气工程、定量生物学和经济学等等。数据大小如下图:

2 数据介绍

  • 数据集格式如下图:
  • 数据集实例:
"root":{"id":string"0704.0001""submitter":string"Pavel Nadolsky""authors":string"C. Bal\'azs, E. L. Berger, P. M. Nadolsky, C.-P. Yuan""title":string"Calculation of prompt diphoton production cross sections at Tevatron and LHC energies""comments":string"37 pages, 15 figures; published version""journal-ref":string"Phys.Rev.D76:013009,2007""doi":string"10.1103/PhysRevD.76.013009""report-no":string"ANL-HEP-PR-07-12""categories":string"hep-ph""license":NULL"abstract":string"  A fully differential calculation in perturbative quantum chromodynamics is presented for the production of massive photon pairs at hadron colliders. All next-to-leading order perturbative contributions from quark-antiquark, gluon-(anti)quark, and gluon-gluon subprocesses are included, as well as all-orders resummation of initial-state gluon radiation valid at next-to-next-to leading logarithmic accuracy. The region of phase space is specified in which the calculation is most reliable. Good agreement is demonstrated with data from the Fermilab Tevatron, and predictions are made for more detailed tests with CDF and DO data. Predictions are shown for distributions of diphoton pairs produced at the energy of the Large Hadron Collider (LHC). Distributions of the diphoton pairs from the decay of a Higgs boson are contrasted with those produced from QCD processes at the LHC, showing that enhanced sensitivity to the signal can be obtained with judicious selection of events.""versions":[0:{"version":string"v1""created":string"Mon, 2 Apr 2007 19:18:42 GMT"}1:{"version":string"v2""created":string"Tue, 24 Jul 2007 20:10:27 GMT"}]"update_date":string"2008-11-26""authors_parsed":[0:[0:string"Balázs"1:string"C."2:string""]1:[0:string"Berger"1:string"E. L."2:string""]2:[0:string"Nadolsky"1:string"P. M."2:string""]3:[0:string"Yuan"1:string"C. -P."2:string""]]
}
  • arxiv论文类别介绍

我们从arxiv官网,查询到论文的类别名称以及其解释如下。

链接:https://arxiv.org/help/api/user-manual 的 5.3 小节的 Subject Classifications 的部分,或 https://arxiv.org/category_taxonomy, 具体的153种paper的类别部分如下:

'astro-ph': 'Astrophysics',
'astro-ph.CO': 'Cosmology and Nongalactic Astrophysics',
'astro-ph.EP': 'Earth and Planetary Astrophysics',
'astro-ph.GA': 'Astrophysics of Galaxies',
'cs.AI': 'Artificial Intelligence',
'cs.AR': 'Hardware Architecture',
'cs.CC': 'Computational Complexity',
'cs.CE': 'Computational Engineering, Finance, and Science',
'cs.CV': 'Computer Vision and Pattern Recognition',
'cs.CY': 'Computers and Society',
'cs.DB': 'Databases',
'cs.DC': 'Distributed, Parallel, and Cluster Computing',
'cs.DL': 'Digital Libraries',
'cs.NA': 'Numerical Analysis',
'cs.NE': 'Neural and Evolutionary Computing',
'cs.NI': 'Networking and Internet Architecture',
'cs.OH': 'Other Computer Science',
'cs.OS': 'Operating Systems',

3 具体代码实现

3.1 导入相关package并读取原始数据

当前环境:Ubuntu18.04+Python3.8+jupyter noteboook

# 导入所需的package
import seaborn as sns #用于画图
from bs4 import BeautifulSoup #用于爬取arxiv的数据
import re #用于正则表达式,匹配字符串的模式
import requests #用于网络连接,发送网络请求,使用域名获取对应信息
import json #读取数据,我们的数据为json格式的
import pandas as pd #数据处理,数据分析
import matplotlib.pyplot as plt #画图工具

接着读入数据

# 读入数据data  = [] #初始化
#使用with语句优势:1.自动关闭文件句柄;2.自动显示(处理)文件读取数据异常
with open("arxiv-metadata-oai-snapshot.json", 'r') as f: for line in f: data.append(json.loads(line)) #这里读入的是全部数据,接近18w,可根据需求进行数据的读写data = pd.DataFrame(data) #将list变为dataframe格式,方便使用pandas进行分析
data.shape #显示数据大小


其中的1796911表示数据总量,14表示特征数,也就是之前所说的id什么的。
下面我们看一下该数据集的前5行,用head()函数。这里只截图了一少部分,右边的行数还有部分未截。

对数据进行读入后,接下来就是数据预处理。

3.2 数据预处理

首先先初略统计一下论文的种类信息:

这个结果表明:共有1796911个数据,有62055个子类(因为有论文的类别是多个,例如一篇paper的类别是CS.AI & CS.MM和一篇paper的类别是CS.AI & CS.OS属于不同的子类别,这里仅仅是粗略统计),其中最多的种类是astro-ph,即Astrophysics(天体物理学),共出现了86914次。

由于部分论文的类别不止一种,所以下面我们判断在本数据集中共出现了多少种独立的数据集。

这里使用了 split 函数将多类别使用 “ ”(空格)分开,组成list,并使用 for 循环将独立出现的类别找出来,并使用 set 类别,将重复项去除得到最终所有的独立paper种类。

从以上结果发现,共有176种论文种类,比我们直接从 https://arxiv.org/help/api/user-manual 的 5.3 小节的 Subject Classifications 的部分或 https://arxiv.org/category_taxonomy中的到的类别少,这说明存在一些官网上没有的类别,这是一个小细节。不过对于我们的计算机方向的论文没有影响,依然是以下的40个类别,我们从原数据中提取的和从官网的到的种类是可以一一对应的。

'cs.AI': 'Artificial Intelligence',
'cs.AR': 'Hardware Architecture',
'cs.CC': 'Computational Complexity',
'cs.CE': 'Computational Engineering, Finance, and Science',
'cs.CG': 'Computational Geometry',
'cs.CL': 'Computation and Language',
'cs.CR': 'Cryptography and Security',
'cs.CV': 'Computer Vision and Pattern Recognition',
'cs.CY': 'Computers and Society',
'cs.DB': 'Databases',
'cs.DC': 'Distributed, Parallel, and Cluster Computing',
'cs.DL': 'Digital Libraries',
'cs.DM': 'Discrete Mathematics',
'cs.DS': 'Data Structures and Algorithms',
'cs.ET': 'Emerging Technologies',
'cs.FL': 'Formal Languages and Automata Theory',
'cs.GL': 'General Literature',
'cs.GR': 'Graphics',
'cs.GT': 'Computer Science and Game Theory',
'cs.HC': 'Human-Computer Interaction',
'cs.IR': 'Information Retrieval',
'cs.IT': 'Information Theory',
'cs.LG': 'Machine Learning',
'cs.LO': 'Logic in Computer Science',
'cs.MA': 'Multiagent Systems',
'cs.MM': 'Multimedia',
'cs.MS': 'Mathematical Software',
'cs.NA': 'Numerical Analysis',
'cs.NE': 'Neural and Evolutionary Computing',
'cs.NI': 'Networking and Internet Architecture',
'cs.OH': 'Other Computer Science',
'cs.OS': 'Operating Systems',
'cs.PF': 'Performance',
'cs.PL': 'Programming Languages',
'cs.RO': 'Robotics',
'cs.SC': 'Symbolic Computation',
'cs.SD': 'Sound',
'cs.SE': 'Software Engineering',
'cs.SI': 'Social and Information Networks',
'cs.SY': 'Systems and Control',

对于2019年以后的paper进行分析,所以首先对于时间特征进行预处理,从而得到2019年以后的所有种类的论文:

data["year"] = pd.to_datetime(data["update_date"]).dt.year #将update_date从例如2019-02-20的str变为datetime格式,并提取处year
del data["update_date"] #删除 update_date特征,其使命已完成
data = data[data["year"] >= 2019] #找出 year 中2019年以后的数据,并将其他数据删除
# data.groupby(['categories','year']) #以 categories 进行排序,如果同一个categories 相同则使用 year 特征进行排序
data.reset_index(drop=True, inplace=True) #重新编号
data #查看结果

这里我们就已经得到了所有2019年以后的论文,下面我们挑选出计算机领域内的所有文章:

#爬取所有的类别
website_url = requests.get('https://arxiv.org/category_taxonomy').text #获取网页的文本数据
soup = BeautifulSoup(website_url,'lxml') #爬取数据,这里使用lxml的解析器,加速
root = soup.find('div',{'id':'category_taxonomy_list'}) #找出 BeautifulSoup 对应的标签入口
tags = root.find_all(["h2","h3","h4","p"], recursive=True) #读取 tags#初始化 str 和 list 变量
level_1_name = ""
level_2_name = ""
level_2_code = ""
level_1_names = []
level_2_codes = []
level_2_names = []
level_3_codes = []
level_3_names = []
level_3_notes = []#进行
for t in tags:if t.name == "h2":level_1_name = t.text    level_2_code = t.textlevel_2_name = t.textelif t.name == "h3":raw = t.textlevel_2_code = re.sub(r"(.*)\((.*)\)",r"\2",raw) #正则表达式:模式字符串:(.*)\((.*)\);被替换字符串"\2";被处理字符串:rawlevel_2_name = re.sub(r"(.*)\((.*)\)",r"\1",raw)elif t.name == "h4":raw = t.textlevel_3_code = re.sub(r"(.*) \((.*)\)",r"\1",raw)level_3_name = re.sub(r"(.*) \((.*)\)",r"\2",raw)elif t.name == "p":notes = t.textlevel_1_names.append(level_1_name)level_2_names.append(level_2_name)level_2_codes.append(level_2_code)level_3_names.append(level_3_name)level_3_codes.append(level_3_code)level_3_notes.append(notes)#根据以上信息生成dataframe格式的数据
df_taxonomy = pd.DataFrame({'group_name' : level_1_names,'archive_name' : level_2_names,'archive_id' : level_2_codes,'category_name' : level_3_names,'categories' : level_3_codes,'category_description': level_3_notes})#按照 "group_name" 进行分组,在组内使用 "archive_name" 进行排序
df_taxonomy.groupby(["group_name","archive_name"])
df_taxonomy

3.3 数据分析及可视化

接下来首先看一下所有大类的paper数量分布:

_df = data.merge(df_taxonomy, on="categories", how="left").drop_duplicates(["id","group_name"]).groupby("group_name").agg({"id":"count"}).sort_values(by="id",ascending=False).reset_index()_df

使用merge函数,以两个dataframe共同的属性 “categories” 进行合并,并以 “group_name” 作为类别进行统计,统计结果放入 “id” 列中并排序。

接着我们使用饼图进行上图结果的可视化:

fig = plt.figure(figsize=(15,12))
explode = (0, 0, 0, 0.2, 0.3, 0.3, 0.2, 0.1)
plt.pie(_df["id"],  labels=_df["group_name"], autopct='%1.2f%%', startangle=160, explode=explode)
plt.tight_layout()
plt.show()


下面统计在计算机各个子领域2019年后的paper数量:

group_name="Computer Science"
cats = data.merge(df_taxonomy, on="categories").query("group_name == @group_name")
cats.groupby(["year","category_name"]).count().reset_index().pivot(index="category_name", columns="year",values="id")

我们同样使用 merge 函数,对于两个dataframe 共同的特征 categories 进行合并并且进行查询。然后我们再对于数据进行统计和排序从而得到以下的结果:

总结

我们可以从结果看出,Computer Vision and Pattern Recognition(计算机视觉与模式识别)类是CS中paper数量最多的子类,遥遥领先于其他的CS子类,并且paper的数量还在逐年增加;另外,Computation and Language(计算与语言)、Cryptography and Security(密码学与安全)以及 Robotics(机器人学)的2019年paper数量均超过1000或接近1000,这与我们的认知是一致的。

数据分析-学术前沿趋势分析一相关推荐

  1. 阿里云天池学习赛-零基础入门数据分析-学术前沿趋势分析(task1)

    阿里云天池学习赛零基础入门数据分析-学术前沿趋势分析 前言 一.赛题描述及数据说明 1:数据集的格式如下: 2:数据集格式举例: 二.task1论文数量统计(数据统计任务):统计2019年全年,计算机 ...

  2. 数据分析入门(学术前沿趋势分析)Task1-论文数据统计

    此次赛题是零基础入门数据分析(学术前沿趋势分析),使用公开的arXiv论文完成对应的数据分析操作.赛题内容包括对论文数量.作者出现频率.论文源码的统计,对论文进行分类以及对论文作者的关系进行建模. 目 ...

  3. Datawhale数据分析学习——学术前沿趋势分析 任务1

    数据分析学习--学术前沿趋势分析 任务1 前言 赛题背景 任务1:论文数据统计 1.1 任务说明 1.2 数据集介绍 1.3 arxiv论文类别介绍 1.4 任务整体思路 1.5 具体代码实现以及讲解 ...

  4. 学术前沿趋势分析(一)

    学术前沿趋势分析(一) 任务说明 数据集 代码实现 数据分析 一.任务说明 任务主题:统计2019年全年计算机各个方向论文数量. 任务内容:赛题的理解.使用 Pandas 读取数据并进行统计. 任务成 ...

  5. 【学术前沿趋势分析 】

    学术前沿趋势分析 Task 01:论文数据统计 Task 02:论文作者统计 Task 03:论文代码统计 Task 04:论文种类分类 Task:5:作者信息关联 Task 01:论文数据统计 任务 ...

  6. 【竞赛算法学习】学术前沿趋势分析-论文数据统计

    任务1:论文数据统计 1.1 任务说明 任务主题:论文数量统计,即统计2019年全年计算机各个方向论文数量: 任务内容:赛题的理解.使用 Pandas 读取数据并进行统计: 任务成果:学习 Panda ...

  7. Datawhale组队学习21期_学术前沿趋势分析Task2_论文作者统计

    任务说明 任务主题:论文作者统计,统计所有论文作者出现评率Top10的姓名: 任务内容:论文作者的统计.使用 Pandas 读取数据并使用字符串操作: 任务成果:学习 Pandas 的字符串操作: 数 ...

  8. 学术前沿趋势分析Task01

    一.任务说明 任务主题:论文数量统计,即统计2019年全年计算机各个方向论文数量: 任务内容:赛题的理解.使用 Pandas 读取数据并进行统计: 任务内容:任务成果:学习 Pandas 的基础操作: ...

  9. 学术前沿趋势分析_学习_论文数据统计Task1

    论文数据统计学习记录 任务说明 分析说明 1. 获得方法:**==使用python 爬虫爬取数据集==** 2. 这里**==使用正则化加以限制==** 3. 判断数据是否存在 4. json文件的设 ...

最新文章

  1. Notification和Notification Manager的使用
  2. Android防火墙原型系统设计,Android系统网络安全性研究及防火墙设计
  3. 我的log4j与logback简易配置
  4. proxool mysql 8小时_java数据库连接池proxool介绍及mysql8小时断开连接问题的说明
  5. Spring4.x学习(1)
  6. 23种设计模式(3)-原型模式
  7. dom元素滚动条高度 js_js浏览器滚动条卷去的高度scrolltop(实例讲解)
  8. 克隆硬盘后进不去系统_升级系统盘,迁移系统其实很简单
  9. transition css3 渐变效果
  10. Git:拉取远程分支
  11. matlab有shapely包吗,[哈工大]Modelarts NPU 安装shapely包失败
  12. sprint会议记录
  13. java属性日期_java时间日期使用与查询代码详解
  14. 隐马尔科夫模型(HMM)学习笔记二
  15. Docker之使用maven插件【Dockerfile方式】构建并推送镜像到私有仓库
  16. 用 RPM 打包软件,第 2 部分
  17. comsol圆柱形永磁体_基于COMSOL Multiphysics的磁场仿真分析
  18. 从0到10亿,微信后台架构及基础设施设计与实践!
  19. 数据可视化分析教学课件——FineBI实验册节选====门店分析
  20. 鲁大师显卡跑分测试软件,鲁大师跑分测试 鲁大师跑分零分怎么办

热门文章

  1. 互联网大佬们,不要再灌996的鸡汤了
  2. HDU - 1862 EXCEL排序 【排序】
  3. 《淘宝技术这十年》使用LAMP架构开发的网站
  4. 抖音短视频开发为什么越来越火热?
  5. leetcode刷题总结
  6. python屏幕截图并保存_用Python保存屏幕截图(不使用PIL)
  7. 【算法】求两个正整数的最大公约数和最小公倍数
  8. #error 、#warning
  9. Python 遍历列表
  10. python turtle 椭圆_Python易学就会(五)turtle绘制椭圆与递归