PHP中文网2017-04-18 09:05:54
一般來講,做cross validation的時候,大家會把k設為5或10。也就是說,將資料(隨機)分成k
份,其中k-1
份为训练,1
份做測試。不過話說回來,都要做cross validation了,應該是快不了的。
PHP中文网2017-04-18 09:05:54
可以用3.1. Cross-validation: evaluating estimator performance
>>> from sklearn.model_selection import cross_val_score
>>> clf = svm.SVC(kernel='linear', C=1)
>>> scores = cross_val_score(clf, iris.data, iris.target, cv=5)
>>> scores
array([ 0.96..., 1. ..., 0.96..., 0.96..., 1. ])