@@ -309,7 +309,7 @@ def fit(self, X, y, sample_weight=None, check_input=True):
309
309
310
310
return self
311
311
312
- def predict (self , X ):
312
+ def predict (self , X , check_input = True ):
313
313
"""Predict class or regression value for X.
314
314
315
315
For a classification model, the predicted class for each sample in X is
@@ -323,16 +323,21 @@ def predict(self, X):
323
323
``dtype=np.float32`` and if a sparse matrix is provided
324
324
to a sparse ``csr_matrix``.
325
325
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
+
326
330
Returns
327
331
-------
328
332
y : array of shape = [n_samples] or [n_samples, n_outputs]
329
333
The predicted classes, or the predict values.
330
334
"""
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" )
336
341
337
342
n_samples , n_features = X .shape
338
343
@@ -541,12 +546,16 @@ def __init__(self,
541
546
class_weight = class_weight ,
542
547
random_state = random_state )
543
548
544
- def predict_proba (self , X ):
549
+ def predict_proba (self , X , check_input = True ):
545
550
"""Predict class probabilities of the input samples X.
546
551
547
552
The predicted class probability is the fraction of samples of the same
548
553
class in a leaf.
549
554
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
+
550
559
Parameters
551
560
----------
552
561
X : array-like or sparse matrix of shape = [n_samples, n_features]
@@ -562,11 +571,12 @@ class in a leaf.
562
571
classes corresponds to that in the attribute `classes_`.
563
572
"""
564
573
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" )
570
580
571
581
n_samples , n_features = X .shape
572
582
0 commit comments