2525import numpy as np
2626from numpy .core .umath_tests import inner1d
2727
28+ from scipy .sparse import coo_matrix
29+ from scipy .sparse import issparse
30+
2831from .base import BaseEnsemble
2932from ..base import ClassifierMixin , RegressorMixin
3033from ..externals import six
3437from ..utils import array2d , check_arrays , check_random_state , column_or_1d
3538from ..utils import safe_asarray
3639from ..metrics import accuracy_score , r2_score
37- from scipy .sparse import coo_matrix
3840
3941__all__ = [
4042 'AdaBoostClassifier' ,
@@ -96,6 +98,9 @@ def fit(self, X, y, sample_weight=None):
9698 X = X .tocsr ()
9799 X = safe_asarray (X )
98100
101+ if (X .ndim != 2 and not issparse (X )):
102+ X = array2d (X )
103+
99104 X , = check_arrays (X , dtype = DTYPE )
100105 X , y = check_arrays (X , y , check_ccontiguous = True )
101106
@@ -205,7 +210,7 @@ def staged_score(self, X, y, sample_weight=None):
205210 ----------
206211 X : {array-like, sparse matrix} of shape = [n_samples, n_features]
207212 The training input samples. Sparse matrix can be csc, csr, coo,
208- dok, or lil. coo, dok, and lil are converted to csr.
213+ dok, or lil. dok, and lil are converted to csr.
209214
210215 y : array-like, shape = [n_samples]
211216 Labels for X.
@@ -364,7 +369,7 @@ def fit(self, X, y, sample_weight=None):
364369 ----------
365370 X : {array-like, sparse matrix} of shape = [n_samples, n_features]
366371 The training input samples. Sparse matrix can be csc, csr, coo,
367- dok, or lil. coo, dok, and lil are converted to csr.
372+ dok, or lil. dok, and lil are converted to csr.
368373
369374 y : array-like of shape = [n_samples]
370375 The target values (class labels).
@@ -415,7 +420,7 @@ def _boost(self, iboost, X, y, sample_weight):
415420
416421 X : {array-like, sparse matrix} of shape = [n_samples, n_features]
417422 The training input samples. Sparse matrix can be csc, csr, coo,
418- dok, or lil. coo, dok, and lil are converted to csr.
423+ dok, or lil. dok, and lil are converted to csr.
419424
420425 y : array-like of shape = [n_samples]
421426 The target values (class labels).
@@ -564,7 +569,7 @@ def predict(self, X):
564569 ----------
565570 X : {array-like, sparse matrix} of shape = [n_samples, n_features]
566571 The training input samples. Sparse matrix can be csc, csr, coo,
567- dok, or lil. coo, dok, and lil are converted to csr.
572+ dok, or lil. dok, and lil are converted to csr.
568573
569574 Returns
570575 -------
@@ -617,7 +622,7 @@ def decision_function(self, X):
617622 ----------
618623 X : {array-like, sparse matrix} of shape = [n_samples, n_features]
619624 The training input samples. Sparse matrix can be csc, csr, coo,
620- dok, or lil. coo, dok, and lil are converted to csr.
625+ dok, or lil. dok, and lil are converted to csr.
621626
622627 Returns
623628 -------
@@ -661,7 +666,7 @@ def staged_decision_function(self, X):
661666 ----------
662667 X : {array-like, sparse matrix} of shape = [n_samples, n_features]
663668 The training input samples. Sparse matrix can be csc, csr, coo,
664- dok, or lil. coo, dok, and lil are converted to csr.
669+ dok, or lil. dok, and lil are converted to csr.
665670
666671 Returns
667672 -------
@@ -715,7 +720,7 @@ def predict_proba(self, X):
715720 ----------
716721 X : {array-like, sparse matrix} of shape = [n_samples, n_features]
717722 The training input samples. Sparse matrix can be csc, csr, coo,
718- dok, or lil. coo, dok, and lil are converted to csr.
723+ dok, or lil. dok, and lil are converted to csr.
719724
720725 Returns
721726 -------
@@ -759,7 +764,7 @@ def staged_predict_proba(self, X):
759764 ----------
760765 X : {array-like, sparse matrix} of shape = [n_samples, n_features]
761766 The training input samples. Sparse matrix can be csc, csr, coo,
762- dok, or lil. coo, dok, and lil are converted to csr.
767+ dok, or lil. dok, and lil are converted to csr.
763768
764769 Returns
765770 -------
@@ -804,7 +809,7 @@ def predict_log_proba(self, X):
804809 ----------
805810 X : {array-like, sparse matrix} of shape = [n_samples, n_features]
806811 The training input samples. Sparse matrix can be csc, csr, coo,
807- dok, or lil. coo, dok, and lil are converted to csr.
812+ dok, or lil. dok, and lil are converted to csr.
808813
809814 Returns
810815 -------
@@ -900,7 +905,7 @@ def fit(self, X, y, sample_weight=None):
900905 ----------
901906 X : {array-like, sparse matrix} of shape = [n_samples, n_features]
902907 The training input samples. Sparse matrix can be csc, csr, coo,
903- dok, or lil. coo, dok, and lil are converted to csr.
908+ dok, or lil. dok, and lil are converted to csr.
904909
905910 y : array-like of shape = [n_samples]
906911 The target values (real numbers).
@@ -940,7 +945,7 @@ def _boost(self, iboost, X, y, sample_weight):
940945
941946 X : {array-like, sparse matrix} of shape = [n_samples, n_features]
942947 The training input samples. Sparse matrix can be csc, csr, coo,
943- dok, or lil. coo, dok, and lil are converted to csr.
948+ dok, or lil. dok, and lil are converted to csr.
944949
945950 y : array-like of shape = [n_samples]
946951 The target values (class labels in classification, real numbers in
@@ -1050,7 +1055,7 @@ def predict(self, X):
10501055 ----------
10511056 X : {array-like, sparse matrix} of shape = [n_samples, n_features]
10521057 The training input samples. Sparse matrix can be csc, csr, coo,
1053- dok, or lil. coo, dok, and lil are converted to csr.
1058+ dok, or lil. dok, and lil are converted to csr.
10541059
10551060 Returns
10561061 -------
@@ -1076,7 +1081,7 @@ def staged_predict(self, X):
10761081 ----------
10771082 X : {array-like, sparse matrix} of shape = [n_samples, n_features]
10781083 The training input samples. Sparse matrix can be csc, csr, coo,
1079- dok, or lil. coo, dok, and lil are converted to csr.
1084+ dok, or lil. dok, and lil are converted to csr.
10801085
10811086 Returns
10821087 -------
0 commit comments