Dataset viewer 文档

数据类型

Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始

数据类型

Dataset viewer 支持的数据集具有表格格式,这意味着一个数据点在一行中表示,其特征包含在列中。使用 /first-rows 端点允许您预览数据集的前 100 行以及有关每个特征的信息。在 features 键中,您会注意到它返回一个 _type 字段。此值描述了列的数据类型,它也被称为数据集的 Features

有几种不同的数据 Features 用于表示不同的数据格式,例如用于语音数据的 Audio 和用于图像数据的 Image。了解数据集特征可以让您更好地理解您正在处理的数据类型,以及如何预处理它。

例如,Rotten Tomatoes 数据集的 /first-rows 端点返回以下内容

{"dataset": "cornell-movie-review-data/rotten_tomatoes",
 "config": "default",
 "split": "train",
 "features": [{"feature_idx": 0,
   "name": "text",
   "type": {"dtype": "string", 
   "id": null,
   "_type": "Value"}},
  {"feature_idx": 1,
   "name": "label",
   "type": {"num_classes": 2,
    "names": ["neg", "pos"],
    "id": null,
    "_type": "ClassLabel"}}],
  ...
 }

此数据集有两列,textlabel

  • text 列的类型为 ValueValue 类型非常通用,表示标量值,例如字符串、整数、日期,甚至时间戳值。

  • label 列的类型为 ClassLabelClassLabel 类型表示数据集中类的数量及其标签名称。自然地,这意味着您会经常在分类数据集中看到 ClassLabel

有关可用数据类型的完整列表,请查看 Features 文档。

< > 在 GitHub 上更新