AI术语词典

A comprehensive multilingual AI terminology dictionary

Definition

留一法交叉验证(LOOCV)是k折交叉验证的一种特殊情况,其中k等于数据集中的样本数量。它提供了对模型性能的近乎无偏的估计,因为每次训练都使用了尽可能多的数据,从而最大限度地减少了偏差。然而,这种方法计算成本较高,因为需要为每个样本重新训练模型。

Summary

一种严格的重采样技术,模型在除一个样本外的所有样本上进行训练,并在该单个保留样本上进行测试,对每个数据点重复此过程。

Key Concepts

Use Cases

Code Example

1
2
3
4
5
6
7
from sklearn.model_selection import LeaveOneOut
loo = LeaveOneOut()
for train_index, test_index in loo.split(X):
    X_train, X_test = X[train_index], X[test_index]
    y_train, y_test = y[train_index], y[test_index]
    model.fit(X_train, y_train)
    score = model.score(X_test, y_test)