假新闻数据集
- class dgl.data.FakeNewsDataset(name, feature_name, raw_dir=None, transform=None)[source]
Bases:
DGLBuiltinDataset
虚假新闻图分类数据集。
该数据集由从Twitter提取的两组树状结构的假/真新闻传播图组成。与大多数用于图分类任务的基准数据集不同,该数据集中的图是有向树状结构图,其中根节点代表新闻,叶节点是转发了根新闻的Twitter用户。此外,节点特征是使用不同的预训练语言模型编码的用户历史推文:
bert: 由bert-as-service编码的Twitter用户历史推文组成的768维节点特征
内容:由300维“spacy”向量和10维“profile”向量组成的310维节点特征
profile: 由十个Twitter用户资料属性组成的10维节点特征。
spacy: 由Twitter用户历史推文通过spaCy word2vec编码器编码组成的300维节点特征。
参考: <https://github.com/safe-graph/GNN-FakeNews>
注意:此数据集仅供学术使用,禁止商业用途。
统计:
政治事实:
图表:314
节点数:41,054
边数: 40,740
类:
假:157
实际值: 157
节点特征大小:
bert: 768
内容: 310
个人资料: 10
spacy: 300
Gossipcop:
图表:5,464
节点数:314,262
边数: 308,798
类:
虚假: 2,732
实际: 2,732
节点特征大小:
bert: 768
内容: 310
个人资料: 10
spacy: 300
- Parameters:
name (str) – 数据集的名称(gossipcop 或 politifact)
feature_name (str) – 特征的名称(bert, content, profile, 或 spacy)
raw_dir (str) – Specifying the directory that will store the downloaded data or the directory that already stores the input data. Default: ~/.dgl/
transform (callable, optional) – A transform that takes in a
DGLGraph
object and returns a transformed version. TheDGLGraph
object will be transformed before every access.
- labels
图形标签
- Type:
张量
- feature
节点特性
- Type:
张量
- train_mask
训练集的掩码
- Type:
张量
- val_mask
验证集的掩码
- Type:
张量
- test_mask
测试集的掩码
- Type:
张量
示例
>>> dataset = FakeNewsDataset('gossipcop', 'bert') >>> graph, label = dataset[0] >>> num_classes = dataset.num_classes >>> feat = dataset.feature >>> labels = dataset.labels
- __getitem__(i)[source]
通过索引获取图形和标签
- Parameters:
i (int) – 项目索引
- Return type:
(
dgl.DGLGraph
, Tensor)