def _cv_len(cv, X, y):
"""This method computes the length of a cross validation
object, agnostic of whether sklearn-0.17 or sklearn-0.18
is being used.
Parameters
----------
cv : `sklearn.cross_validation._PartitionIterator` or `sklearn.model_selection.BaseCrossValidator`
The cv object from which to extract length. If using
sklearn-0.17, this can be computed by calling `len` on
``cv``, else it's computed with `cv.get_n_splits(X, y)`.
X : pd.DataFrame or np.ndarray, shape(n_samples, n_features)
The dataframe or np.ndarray being fit in the grid search.
y : np.ndarray, shape(n_samples,)
The target being fit in the grid search.
Returns
-------
int
"""
return len(cv) if not SK18 else cv.get_n_splits(X, y)
评论列表
文章目录