@@ -309,7 +309,7 @@ def fit(self, X, y, sample_weight=None, check_input=True):
309309
310310 return self
311311
312- def predict (self , X ):
312+ def predict (self , X , check_input = True ):
313313 """Predict class or regression value for X.
314314
315315 For a classification model, the predicted class for each sample in X is
@@ -323,16 +323,21 @@ def predict(self, X):
323323 ``dtype=np.float32`` and if a sparse matrix is provided
324324 to a sparse ``csr_matrix``.
325325
326+ check_input : boolean, (default=True)
327+ Allow to bypass several input checking.
328+ Don't use this parameter unless you know what you do.
329+
326330 Returns
327331 -------
328332 y : array of shape = [n_samples] or [n_samples, n_outputs]
329333 The predicted classes, or the predict values.
330334 """
331- X = check_array (X , dtype = DTYPE , accept_sparse = "csr" )
332- if issparse (X ) and (X .indices .dtype != np .intc or
333- X .indptr .dtype != np .intc ):
334- raise ValueError ("No support for np.int64 index based "
335- "sparse matrices" )
335+ if check_input :
336+ X = check_array (X , dtype = DTYPE , accept_sparse = "csr" )
337+ if issparse (X ) and (X .indices .dtype != np .intc or
338+ X .indptr .dtype != np .intc ):
339+ raise ValueError ("No support for np.int64 index based "
340+ "sparse matrices" )
336341
337342 n_samples , n_features = X .shape
338343
@@ -541,12 +546,16 @@ def __init__(self,
541546 class_weight = class_weight ,
542547 random_state = random_state )
543548
544- def predict_proba (self , X ):
549+ def predict_proba (self , X , check_input = True ):
545550 """Predict class probabilities of the input samples X.
546551
547552 The predicted class probability is the fraction of samples of the same
548553 class in a leaf.
549554
555+ check_input : boolean, (default=True)
556+ Allow to bypass several input checking.
557+ Don't use this parameter unless you know what you do.
558+
550559 Parameters
551560 ----------
552561 X : array-like or sparse matrix of shape = [n_samples, n_features]
@@ -562,11 +571,12 @@ class in a leaf.
562571 classes corresponds to that in the attribute `classes_`.
563572 """
564573 check_is_fitted (self , 'n_outputs_' )
565- X = check_array (X , dtype = DTYPE , accept_sparse = "csr" )
566- if issparse (X ) and (X .indices .dtype != np .intc or
567- X .indptr .dtype != np .intc ):
568- raise ValueError ("No support for np.int64 index based "
569- "sparse matrices" )
574+ if check_input :
575+ X = check_array (X , dtype = DTYPE , accept_sparse = "csr" )
576+ if issparse (X ) and (X .indices .dtype != np .intc or
577+ X .indptr .dtype != np .intc ):
578+ raise ValueError ("No support for np.int64 index based "
579+ "sparse matrices" )
570580
571581 n_samples , n_features = X .shape
572582
0 commit comments