Skip to content

Commit fd1e316

Browse files
committed
Enforced dtype for X, and clarified documentation by indcating the sparse formats supported and how they are treated
1 parent fef730a commit fd1e316

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

sklearn/ensemble/weight_boosting.py

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def fit(self, X, y, sample_weight=None):
7171
Parameters
7272
----------
7373
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
74-
The training input samples.
74+
The training input samples. Sparse matrix can be csc, csr, coo,
75+
dok, or lil. coo, dok, and lil are converted to csr.
7576
7677
y : array-like of shape = [n_samples]
7778
The target values (class labels in classification, real numbers in
@@ -95,7 +96,9 @@ def fit(self, X, y, sample_weight=None):
9596
X = X.tocsr()
9697
X = safe_asarray(X)
9798

99+
X, = check_arrays(X, dtype=DTYPE)
98100
X, y = check_arrays(X, y, check_ccontiguous=True)
101+
99102
y = column_or_1d(y, warn=True)
100103

101104
if sample_weight is None:
@@ -166,7 +169,8 @@ def _boost(self, iboost, X, y, sample_weight):
166169
The index of the current boost iteration.
167170
168171
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
169-
The training input samples.
172+
The training input samples. Sparse matrix can be csc, csr, coo,
173+
dok, or lil. coo, dok, and lil are converted to csr.
170174
171175
y : array-like of shape = [n_samples]
172176
The target values (class labels).
@@ -199,8 +203,9 @@ def staged_score(self, X, y, sample_weight=None):
199203
200204
Parameters
201205
----------
202-
X : {array-like, sparse matrix}, shape = [n_samples, n_features]
203-
Training set.
206+
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
207+
The training input samples. Sparse matrix can be csc, csr, coo,
208+
dok, or lil. coo, dok, and lil are converted to csr.
204209
205210
y : array-like, shape = [n_samples]
206211
Labels for X.
@@ -358,7 +363,8 @@ def fit(self, X, y, sample_weight=None):
358363
Parameters
359364
----------
360365
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
361-
The training input samples.
366+
The training input samples. Sparse matrix can be csc, csr, coo,
367+
dok, or lil. coo, dok, and lil are converted to csr.
362368
363369
y : array-like of shape = [n_samples]
364370
The target values (class labels).
@@ -408,7 +414,8 @@ def _boost(self, iboost, X, y, sample_weight):
408414
The index of the current boost iteration.
409415
410416
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
411-
The training input samples.
417+
The training input samples. Sparse matrix can be csc, csr, coo,
418+
dok, or lil. coo, dok, and lil are converted to csr.
412419
413420
y : array-like of shape = [n_samples]
414421
The target values (class labels).
@@ -556,7 +563,8 @@ def predict(self, X):
556563
Parameters
557564
----------
558565
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
559-
The input samples.
566+
The training input samples. Sparse matrix can be csc, csr, coo,
567+
dok, or lil. coo, dok, and lil are converted to csr.
560568
561569
Returns
562570
-------
@@ -608,7 +616,8 @@ def decision_function(self, X):
608616
Parameters
609617
----------
610618
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
611-
The input samples.
619+
The training input samples. Sparse matrix can be csc, csr, coo,
620+
dok, or lil. coo, dok, and lil are converted to csr.
612621
613622
Returns
614623
-------
@@ -651,7 +660,8 @@ def staged_decision_function(self, X):
651660
Parameters
652661
----------
653662
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
654-
The input samples.
663+
The training input samples. Sparse matrix can be csc, csr, coo,
664+
dok, or lil. coo, dok, and lil are converted to csr.
655665
656666
Returns
657667
-------
@@ -704,7 +714,8 @@ def predict_proba(self, X):
704714
Parameters
705715
----------
706716
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
707-
The input samples.
717+
The training input samples. Sparse matrix can be csc, csr, coo,
718+
dok, or lil. coo, dok, and lil are converted to csr.
708719
709720
Returns
710721
-------
@@ -747,7 +758,8 @@ def staged_predict_proba(self, X):
747758
Parameters
748759
----------
749760
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
750-
The input samples.
761+
The training input samples. Sparse matrix can be csc, csr, coo,
762+
dok, or lil. coo, dok, and lil are converted to csr.
751763
752764
Returns
753765
-------
@@ -791,7 +803,8 @@ def predict_log_proba(self, X):
791803
Parameters
792804
----------
793805
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
794-
The input samples.
806+
The training input samples. Sparse matrix can be csc, csr, coo,
807+
dok, or lil. coo, dok, and lil are converted to csr.
795808
796809
Returns
797810
-------
@@ -886,7 +899,8 @@ def fit(self, X, y, sample_weight=None):
886899
Parameters
887900
----------
888901
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
889-
The training input samples.
902+
The training input samples. Sparse matrix can be csc, csr, coo,
903+
dok, or lil. coo, dok, and lil are converted to csr.
890904
891905
y : array-like of shape = [n_samples]
892906
The target values (real numbers).
@@ -925,7 +939,8 @@ def _boost(self, iboost, X, y, sample_weight):
925939
The index of the current boost iteration.
926940
927941
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
928-
The training input samples.
942+
The training input samples. Sparse matrix can be csc, csr, coo,
943+
dok, or lil. coo, dok, and lil are converted to csr.
929944
930945
y : array-like of shape = [n_samples]
931946
The target values (class labels in classification, real numbers in
@@ -1034,7 +1049,8 @@ def predict(self, X):
10341049
Parameters
10351050
----------
10361051
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
1037-
The input samples.
1052+
The training input samples. Sparse matrix can be csc, csr, coo,
1053+
dok, or lil. coo, dok, and lil are converted to csr.
10381054
10391055
Returns
10401056
-------
@@ -1059,7 +1075,8 @@ def staged_predict(self, X):
10591075
Parameters
10601076
----------
10611077
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
1062-
The input samples.
1078+
The training input samples. Sparse matrix can be csc, csr, coo,
1079+
dok, or lil. coo, dok, and lil are converted to csr.
10631080
10641081
Returns
10651082
-------

0 commit comments

Comments
 (0)