Cross-validation
Cross-validation in ScikitLearn.jl is the same as in scikit-learn:
using ScikitLearn.CrossValidation: cross_val_score
cross_val_score(LogisticRegression(), X, y; cv=5) # 5-fold
See ?cross_val_score
and the user guide for details.
We support all the scikit-learn cross-validation iterators (KFold, StratifiedKFold, etc.) For example:
> ScikitLearn.CrossValidation.KFold(10, n_folds=3)
3-element Array{Tuple{Array{Int64,1},Array{Int64,1}},1}:
([5,6,7,8,9,10],[1,2,3,4])
([1,2,3,4,8,9,10],[5,6,7])
([1,2,3,4,5,6,7],[8,9,10])
These iterators can be passed to cross_val_score
's cv
argument.
Note: the most common iterators have been translated to Julia. The others still require scikit-learn (python) to be installed.
Examples
Cross-validated predictions
cross_val_predict
performs cross-validation and returns the test-set predicted
values. Documentation here