【发布时间】:2020-12-16 05:16:48
【问题描述】:
我正在尝试了解如何使用 Stellargraph 的 EdgeSplitter 类。特别是,文档中的examples,用于训练基于 Node2Vec 的链接预测模型,将图拆分为以下部分:
Distrution of samples across train, val and test set
按照文档中的examples,首先对全图链接的10%进行采样以获得测试集:
# Define an edge splitter on the original graph:
edge_splitter_test = EdgeSplitter(graph)
# Randomly sample a fraction p=0.1 of all positive links, and same number of negative links, from graph, and obtain the
# reduced graph graph_test with the sampled links removed:
graph_test, examples_test, labels_test = edge_splitter_test.train_test_split(
p=0.1, method="global"
)
据我从文档中了解到,graph_test 是原始图表,但删除了测试链接。然后你对训练集执行同样的操作,
# Do the same process to compute a training subset from within the test graph
edge_splitter_train = EdgeSplitter(graph_test)
graph_train, examples, labels = edge_splitter_train.train_test_split(
p=0.1, method="global"
)
按照前面的逻辑,graph_train 对应于graph_test,去掉了训练链接。
进一步深入代码,我的理解是我们使用graph_train 来训练嵌入和训练样本(示例、标签)来训练分类器。所以我在这里有几个问题:
- 我们为什么要使用不相交集的训练数据来训练模型的不同部分?我们不应该使用完整的链接训练集来训练嵌入和分类器吗?
- 为什么测试集这么大?在训练集中包含大多数样本不是更好吗?
-
EdgeSplitter类的正确使用方法是什么?
提前感谢您的帮助!
【问题讨论】:
标签: python machine-learning graph embedding train-test-split