我们会计算*测试*集上的成本 J(θ) 吗?

would we ever compute the cost J(θ) on the *test* set?

我很确定答案是否定的,但想确认...

在训练神经网络或其他学习算法时,我们将计算成本函数 J(θ) 作为我们的算法与训练数据的拟合程度的表达式(较高的值意味着它与数据的拟合程度较低)。在训练我们的算法时,我们通常希望看到 J(theta) 随着梯度下降的每次迭代而下降。

但我很好奇,根据我们的 test 数据计算 J(θ) 是否有价值?

我认为答案是否定的,因为我们只评估一次我们的测试数据,我们只会得到J(θ)的一个值,我认为它没有意义,除非与其他值进行比较。

你的问题涉及到一个非常常见的术语歧义:validationtest 集(Wikipedia entry and this Cross Vaidated post 可能有助于解决这个问题)。

因此,假设您确实指的是正确的测试集而不是验证集,那么:

  1. 你说得对,这个集合只用了一次,就在整个建模过程的最后

  2. 总的来说,你假设我们不计算这个集合中的成本 J(θ) 是不正确的。

详细说明(2):事实上,测试集的唯一用处恰恰是用于评估我们的最终模型,在一个在拟合过程的各个阶段根本没有使用过的集合中(注意validation 集已被间接使用,即用于模型选择);为了评估它,我们显然必须计算成本。

我认为可能造成混淆的原因是您可能只考虑分类设置(尽管您没有在问题中指定);是的,在这种情况下,我们通常对关于 业务 指标(例如准确性)的模型性能感兴趣,而不是关于优化成本 J(θ) 本身。但在 回归 设置中,优化成本和业务指标很可能是一回事(例如 RMSE、MSE、MAE 等)。而且,正如我希望清楚的那样,在这样的设置中计算测试集中的成本绝不是毫无意义的,尽管我们没有将它与其他值进行比较(它为我们提供了 "absolute" 性能指标最终模型)。

您可能会发现我的 and 个关于损失和准确性之间区别的答案很有用;引用这些答案:

Loss and accuracy are different things; roughly speaking, the accuracy is what we are actually interested in from a business perspective, while the loss is the objective function that the learning algorithms (optimizers) are trying to minimize from a mathematical perspective. Even more roughly speaking, you can think of the loss as the "translation" of the business objective (accuracy) to the mathematical domain, a translation which is necessary in classification problems (in regression ones, usually the loss and the business objective are the same, or at least can be the same in principle, e.g. the RMSE)...