53
53
from sklearn .exceptions import DataConversionWarning
54
54
55
55
from sklearn .pipeline import Pipeline
56
- from sklearn .cross_validation import cross_val_score
57
- from sklearn .cross_validation import LeaveOneOut
56
+ from sklearn .cross_validation import cross_val_predict
58
57
from sklearn .svm import SVR
59
58
60
59
from sklearn import datasets
@@ -1379,7 +1378,7 @@ def test_cv_pipeline_precomputed():
1379
1378
value. Use precomputed kernel to ensure Pipeline with KernelCenterer
1380
1379
is treated as a _pairwise operation."""
1381
1380
X = np .array ([[3 ,0 ,0 ],[0 ,3 ,0 ],[0 ,0 ,3 ],[1 ,1 ,1 ]])
1382
- y = np .ones ((4 ,))
1381
+ y_true = np .ones ((4 ,))
1383
1382
K = X .dot (X .T )
1384
1383
kcent = KernelCenterer ()
1385
1384
pipeline = Pipeline ([("kernel_centerer" , kcent ), ("svr" , SVR ())])
@@ -1388,8 +1387,10 @@ def test_cv_pipeline_precomputed():
1388
1387
assert_true (pipeline ._pairwise )
1389
1388
1390
1389
# test cross-validation, score should be almost perfect
1391
- score = cross_val_score (pipeline ,K ,y ,cv = LeaveOneOut (4 ))
1392
- assert_array_almost_equal (score , np .ones_like (score ))
1390
+ # NB: this test is pretty vacuous -- it's mainly to test integration
1391
+ # of Pipeline and KernelCenterer
1392
+ y_pred = cross_val_predict (pipeline ,K ,y_true ,cv = 4 )
1393
+ assert_array_almost_equal (y_true , y_pred )
1393
1394
1394
1395
1395
1396
def test_fit_transform ():
0 commit comments