https://mp.weixin.qq.com/s/PfvgokzPelMJet3aBqgE1w

简介: https://mp.weixin.qq.com/s/PfvgokzPelMJet3aBqgE1w

目录

 

获取和整理NASA元数据

计算tf-idf

关键字和描述

可视化结果


NASA有32,000多个数据集,有关NASA数据集的元数据  可以JSON格式在线获得。我们使用tf-idf在描述字段中找到重要的单词,并将其与关键字联系起来。

获取和整理NASA元数据

让我们下载32,000多个NASA数据集的元数据。


library(jsonlite)
library(dplyr)
library(tidyr)
metadata <- fromJSON("data.json")
names(metadata$dataset)
##  [1] "_id"                "@type"              "accessLevel"        "accrualPeriodicity"
##  [5] "bureauCode"         "contactPoint"       "description"        "distribution"
##  [9] "identifier"         "issued"             "keyword"            "landingPage"
## [13] "language"           "modified"           "programCode"        "publisher"
## [17] "spatial"            "temporal"           "theme"              "title"
## [21] "license"            "isPartOf"           "references"         "rights"
## [25] "describedBy"
nasadesc <- data_frame(id = metadata$dataset$`_id`$`$oid`, desc = metadata$dataset$description)
nasadesc
## # A tibble: 32,089 x 2
##                          id
##                       <chr>
## 1  55942a57c63a7fe59b495a77
## 2  55942a57c63a7fe59b495a78
## 3  55942a58c63a7fe59b495a79
## 4  55942a58c63a7fe59b495a7a
## 5  55942a58c63a7fe59b495a7b
## 6  55942a58c63a7fe59b495a7c
## 7  55942a58c63a7fe59b495a7d
## 8  55942a58c63a7fe59b495a7e
## 9  55942a58c63a7fe59b495a7f
## 10 55942a58c63a7fe59b495a80
## # ... with 32,079 more rows, and 1 more variables: desc <chr>
 
## # A tibble: 32,089 x 2
##                          id
##                       <chr>
## 1  55942a57c63a7fe59b495a77
## 2  55942a57c63a7fe59b495a78
## 3  55942a58c63a7fe59b495a79
## 4  55942a58c63a7fe59b495a7a
## 5  55942a58c63a7fe59b495a7b
## 6  55942a58c63a7fe59b495a7c
## 7  55942a58c63a7fe59b495a7d
## 8  55942a58c63a7fe59b495a7e
## 9  55942a58c63a7fe59b495a7f
## 10 55942a58c63a7fe59b495a80
## # ... with 32,079 more rows, and 1 more variables: desc <chr>


让我们输出其中的一部分。

 
nasadesc %>% select(desc) %>% sample_n(5)
## # A tibble: 5 x 1
##                                                                                                                                                      desc
##                                                                                                                                                     <chr>
## 1  A Group for High Resolution Sea Surface Temperature (GHRSST) Level 4 sea surface temperature analysis produced as a retrospective dataset at the JPL P
## 2  ML2CO is the EOS Aura Microwave Limb Sounder (MLS) standard product for carbon monoxide derived from radiances measured by the 640 GHz radiometer. The
## 3                                                                                                              Crew lock bag. Polygons: 405 Vertices: 514
## 4  JEM Engineering proved the technical feasibility of the FlexScan array?a very low-cost, highly-efficient, wideband phased array antenna?in Phase I, an
## 5 MODIS (or Moderate Resolution Imaging Spectroradiometer) is a key instrument aboard the\nTerra (EOS AM) and Aqua (EOS PM) satellites. Terra's orbit aro

这是关键词。


## # A tibble: 126,814 x 2
##                          id       keyword
##                       <chr>         <chr>
## 1  55942a57c63a7fe59b495a77 EARTH SCIENCE
## 2  55942a57c63a7fe59b495a77   HYDROSPHERE
## 3  55942a57c63a7fe59b495a77 SURFACE WATER
## 4  55942a57c63a7fe59b495a78 EARTH SCIENCE
## 5  55942a57c63a7fe59b495a78   HYDROSPHERE
## 6  55942a57c63a7fe59b495a78 SURFACE WATER
## 7  55942a58c63a7fe59b495a79 EARTH SCIENCE
## 8  55942a58c63a7fe59b495a79   HYDROSPHERE
## 9  55942a58c63a7fe59b495a79 SURFACE WATER
## 10 55942a58c63a7fe59b495a7a EARTH SCIENCE
## # ... with 126,804 more rows

最常见的关键字是什么?


## # A tibble: 1,774 x 2
##                    keyword     n
##                      <chr> <int>
## 1            EARTH SCIENCE 14362
## 2                  Project  7452
## 3               ATMOSPHERE  7321
## 4              Ocean Color  7268
## 5             Ocean Optics  7268
## 6                   Oceans  7268
## 7                completed  6452
## 8  ATMOSPHERIC WATER VAPOR  3142
## 9                   OCEANS  2765
## 10            LAND SURFACE  2720
## # ... with 1,764 more rows

看起来“已完成项目”对于某些目的来说可能不是有用的关键字,我们可能希望将所有这些都更改为小写或大写,以消除如“ OCEANS”和“ Oceans”之类的重复项。

计算文字的tf-idf

什么是tf-idf?评估文档中单词的重要性的一种方法可能是其  术语频率  (tf),即单词在文档中出现的频率。但是,一些经常出现的单词并不重要。在英语中,这些词可能是“ the”,“ is”,“ of”等词。另一种方法是查看术语的  逆文本频率指数 (idf),这会降低常用单词的权重,而增加在文档集中很少使用的单词的权重。


## # A tibble: 2,728,224 x 3
##                          id  word     n
##                       <chr> <chr> <int>
## 1  55942a88c63a7fe59b498280   amp   679
## 2  55942a88c63a7fe59b498280  nbsp   655
## 3  55942a8ec63a7fe59b4986ef    gt   330
## 4  55942a8ec63a7fe59b4986ef    lt   330
## 5  55942a8ec63a7fe59b4986ef     p   327
## 6  55942a8ec63a7fe59b4986ef   the   231
## 7  55942a86c63a7fe59b49803b   amp   208
## 8  55942a86c63a7fe59b49803b  nbsp   204
## 9  56cf5b00a759fdadc44e564a   the   201
## 10 55942a86c63a7fe59b4980a2    gt   191
## # ... with 2,728,214 more rows

这些是NASA字段中最常见的“单词”,是词频最高的单词。让我们看一下第一个数据集,例如:


## # A tibble: 1 x 1
##                                                                                                                                                     desc
##                                                                                                                                                    <chr>
## 1 The objective of the Variable Oxygen Regulator Element is to develop an oxygen-rated, contaminant-tolerant oxygen regulator to control suit p

tf-idf算法应该减少所有这些的权重,因为它们很常见,但是我们可以根据需要通过停用词将其删除。现在,让我们为描述字段中的所有单词计算tf-idf。


## # A tibble: 2,728,224 x 6
##                          id  word     n         tf       idf      tf_idf
##                       <chr> <chr> <int>      <dbl>     <dbl>       <dbl>
## 1  55942a88c63a7fe59b498280   amp   679 0.35661765 3.1810813 1.134429711
## 2  55942a88c63a7fe59b498280  nbsp   655 0.34401261 4.2066578 1.447143322
## 3  55942a8ec63a7fe59b4986ef    gt   330 0.05722213 3.2263517 0.184618705
## 4  55942a8ec63a7fe59b4986ef    lt   330 0.05722213 3.2903671 0.188281801
## 5  55942a8ec63a7fe59b4986ef     p   327 0.05670192 3.3741126 0.191318680
## 6  55942a8ec63a7fe59b4986ef   the   231 0.04005549 0.1485621 0.005950728
## 7  55942a86c63a7fe59b49803b   amp   208 0.32911392 3.1810813 1.046938133
## 8  55942a86c63a7fe59b49803b  nbsp   204 0.32278481 4.2066578 1.357845252
## 9  56cf5b00a759fdadc44e564a   the   201 0.06962245 0.1485621 0.010343258
## 10 55942a86c63a7fe59b4980a2    gt   191 0.12290862 3.2263517 0.396546449
## # ... with 2,728,214 more rows

添加的列是tf,idf,这两个数量相乘在一起是tf-idf。NASA描述字段中最高的tf-idf词是什么?


## # A tibble: 2,728,224 x 6
##                          id                                          word     n    tf       idf
##                       <chr>                                         <chr> <int> <dbl>     <dbl>
## 1  55942a7cc63a7fe59b49774a                                           rdr     1     1 10.376269
## 2  55942ac9c63a7fe59b49b688 palsar_radiometric_terrain_corrected_high_res     1     1 10.376269
## 3  55942ac9c63a7fe59b49b689  palsar_radiometric_terrain_corrected_low_res     1     1 10.376269
## 4  55942a7bc63a7fe59b4976ca                                          lgrs     1     1  8.766831
## 5  55942a7bc63a7fe59b4976d2                                          lgrs     1     1  8.766831
## 6  55942a7bc63a7fe59b4976e3                                          lgrs     1     1  8.766831
## 7  55942ad8c63a7fe59b49cf6c                      template_proddescription     1     1  8.296827
## 8  55942ad8c63a7fe59b49cf6d                      template_proddescription     1     1  8.296827
## 9  55942ad8c63a7fe59b49cf6e                      template_proddescription     1     1  8.296827
## 10 55942ad8c63a7fe59b49cf6f                      template_proddescription     1     1  8.296827
##       tf_idf
##        <dbl>
## 1  10.376269
## 2  10.376269
## 3  10.376269
## 4   8.766831
## 5   8.766831
## 6   8.766831
## 7   8.296827
## 8   8.296827
## 9   8.296827
## 10  8.296827
## # ... with 2,728,214 more rows

因此,这些是用tf-idf衡量的描述字段中最“重要”的词,这意味着它们很常见,但不太常用。


## # A tibble: 1 x 1
##    desc
##   <chr>
## 1   RDR

tf-idf算法认为这非常重要的词。

关键字和描述

因此,现在我们知道描述中的哪个词具有较高的tf-idf,并且在关键字中也有这些描述的标签。


## # A tibble: 11,013,838 x 7
##                          id  word     n         tf      idf    tf_idf              keyword
##                       <chr> <chr> <int>      <dbl>    <dbl>     <dbl>                <chr>
## 1  55942a88c63a7fe59b498280   amp   679 0.35661765 3.181081 1.1344297              ELEMENT
## 2  55942a88c63a7fe59b498280   amp   679 0.35661765 3.181081 1.1344297 JOHNSON SPACE CENTER
## 3  55942a88c63a7fe59b498280   amp   679 0.35661765 3.181081 1.1344297                  VOR
## 4  55942a88c63a7fe59b498280   amp   679 0.35661765 3.181081 1.1344297               ACTIVE
## 5  55942a88c63a7fe59b498280  nbsp   655 0.34401261 4.206658 1.4471433              ELEMENT
## 6  55942a88c63a7fe59b498280  nbsp   655 0.34401261 4.206658 1.4471433 JOHNSON SPACE CENTER
## 7  55942a88c63a7fe59b498280  nbsp   655 0.34401261 4.206658 1.4471433                  VOR
## 8  55942a88c63a7fe59b498280  nbsp   655 0.34401261 4.206658 1.4471433               ACTIVE
## 9  55942a8ec63a7fe59b4986ef    gt   330 0.05722213 3.226352 0.1846187 JOHNSON SPACE CENTER
## 10 55942a8ec63a7fe59b4986ef    gt   330 0.05722213 3.226352 0.1846187              PROJECT
## # ... with 11,013,828 more rows

可视化结果

让我们来看几个示例关键字中最重要的单词。


## # A tibble: 122 x 7
##                          id      word     n        tf      idf   tf_idf    keyword
##                       <chr>    <fctr> <int>     <dbl>    <dbl>    <dbl>      <chr>
## 1  55942a60c63a7fe59b49612f estimates     1 0.5000000 3.172863 1.586432     CLOUDS
## 2  55942a76c63a7fe59b49728d      ncdc     1 0.1666667 7.603680 1.267280     CLOUDS
## 3  55942a60c63a7fe59b49612f     cloud     1 0.5000000 2.464212 1.232106     CLOUDS
## 4  55942a5ac63a7fe59b495bd8      fife     1 0.2000000 5.910360 1.182072     CLOUDS
## 5  55942a5cc63a7fe59b495deb allometry     1 0.1428571 7.891362 1.127337 VEGETATION
## 6  55942a5dc63a7fe59b495ede       tgb     3 0.1875000 5.945452 1.114772 VEGETATION
## 7  55942a5ac63a7fe59b495bd8      tovs     1 0.2000000 5.524238 1.104848     CLOUDS
## 8  55942a5ac63a7fe59b495bd8  received     1 0.2000000 5.332843 1.066569     CLOUDS
## 9  55942a5cc63a7fe59b495dfd       sap     1 0.1250000 8.430358 1.053795 VEGETATION
## 10 55942a60c63a7fe59b496131  abstract     1 0.3333333 3.118561 1.039520     CLOUDS
## # ... with 112 more rows
 
## # A tibble: 1 x 1
##              desc
##             <chr>
## 1 Cloud estimates

tf-idf算法在仅2个字长的描述中无法很好地工作,或者它将对这些字加权过重。这是不合适的。

 

相关文章
|
10月前
|
人工智能 自然语言处理 数据可视化
AutoAgents:比LangChain更激进的AI开发神器!自然语言生成AI智能体军团,1句话搞定复杂任务
AutoAgents 是基于大型语言模型的自动智能体生成框架,能够根据用户设定的目标自动生成多个专家角色的智能体,通过协作完成复杂任务。支持动态生成智能体、任务规划与执行、多智能体协作等功能。
1547 91
|
10月前
|
机器学习/深度学习
《揭秘机器学习中的交叉验证:模型评估的基石》
交叉验证是机器学习中评估模型性能的关键技术,旨在提高模型的可靠性和泛化能力。通过将数据集划分为多个子集,交叉验证有效抵御过拟合风险,最大化数据利用效率,并精准筛选最优模型。常见的方法包括K折交叉验证、留一交叉验证、分层交叉验证和嵌套交叉验证,每种方法适用于不同场景,确保模型在实际应用中表现优异。
1018 1
|
10月前
|
存储 Kubernetes 对象存储
部署DeepSeek但GPU不足,ACK One注册集群助力解决IDC GPU资源不足
部署DeepSeek但GPU不足,ACK One注册集群助力解决IDC GPU资源不足
267 3
|
11月前
|
缓存 测试技术 开发者
如何解决 Postman 报错一直转圈打不开?
缓存过多的时候,打开postman就会出现转圈的现象,所以需要清理下缓存文件。
|
机器学习/深度学习 人工智能 算法
【乐器识别系统】图像识别+人工智能+深度学习+Python+TensorFlow+卷积神经网络+模型训练
乐器识别系统。使用Python为主要编程语言,基于人工智能框架库TensorFlow搭建ResNet50卷积神经网络算法,通过对30种乐器('迪吉里杜管', '铃鼓', '木琴', '手风琴', '阿尔卑斯号角', '风笛', '班卓琴', '邦戈鼓', '卡萨巴', '响板', '单簧管', '古钢琴', '手风琴(六角形)', '鼓', '扬琴', '长笛', '刮瓜', '吉他', '口琴', '竖琴', '沙槌', '陶笛', '钢琴', '萨克斯管', '锡塔尔琴', '钢鼓', '长号', '小号', '大号', '小提琴')的图像数据集进行训练,得到一个训练精度较高的模型,并将其
425 0
【乐器识别系统】图像识别+人工智能+深度学习+Python+TensorFlow+卷积神经网络+模型训练
|
12月前
|
机器学习/深度学习 存储 人工智能
【AI系统】自定义计算图 IR
本文介绍了模型转换的方法及流程,重点讲解了计算图的自定义方法和优化技术。通过IR(Intermediate Representation)将不同AI框架的模型转换为统一格式,实现跨平台高效部署。计算图由张量和算子构成,支持多种数据类型和内存排布格式,通过算子融合等优化技术提高模型性能。文章还详细说明了如何使用FlatBuffers定义计算图结构,包括张量、算子和网络模型的定义,为自定义神经网络提供了实践指南。
344 3
【AI系统】自定义计算图 IR
漂亮的七彩引导页导航HTML源码
漂亮的七彩引导页导航HTML源码,源码由HTML+CSS+JS组成,记事本打开源码文件可以进行内容文字之类的修改,双击html文件可以本地运行效果,也可以上传到服务器里面,重定向这个界面
326 0
漂亮的七彩引导页导航HTML源码
Module build failed (from ./node_modules/eslint-loader/index.js)
Module build failed (from ./node_modules/eslint-loader/index.js)
433 0
Module build failed (from ./node_modules/eslint-loader/index.js)
|
Java API Maven
告别漫长重启时代:Quarkus热部署功能让你的代码改动瞬间生效,提升开发效率的秘密武器揭秘!
Quarkus是一款备受开发者青睐的开源框架,以其轻量级、高性能及出色的云适应性著称。其内置的热部署功能让开发者能在不重启应用的情况下实时预览代码修改效果,显著提升开发效率。本文将深入解析Quarkus热部署的工作原理,并通过示例演示如何启用和使用该功能。首先确保已安装Java 11及以上版本和Maven,然后按照指引创建并运行一个Quarkus项目。通过修改RESTful API端点的返回值,我们可以直观地看到热部署带来的即时效果,从而体验到这一功能为开发流程带来的巨大便利。这对于追求高效开发的技术团队而言,无疑是强大的助力。
335 1