Skip to content

Commit fef730a

Browse files
committed
Revied test_sparse_{regression,classification} to use make_multilabel_classification, revised import statements to adhere to one name per import conventions
1 parent 9e7351d commit fef730a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

sklearn/ensemble/tests/test_weight_boosting.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
from numpy.testing import assert_equal
77
from nose.tools import assert_raises
88

9+
from sklearn.cross_validation import train_test_split
910
from sklearn.grid_search import GridSearchCV
1011
from sklearn.ensemble import AdaBoostClassifier
1112
from sklearn.ensemble import AdaBoostRegressor
12-
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
13+
from scipy.sparse import csc_matrix
14+
from scipy.sparse import csr_matrix
15+
from scipy.sparse import coo_matrix
16+
from scipy.sparse import dok_matrix
17+
from scipy.sparse import lil_matrix
1318
from sklearn.svm import SVC, SVR
19+
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
1420
from sklearn.utils import shuffle
15-
from sklearn.cross_validation import train_test_split
16-
from scipy.sparse import csc_matrix, csr_matrix, coo_matrix, dok_matrix, \
17-
lil_matrix
1821
from sklearn import datasets
1922

2023

@@ -253,7 +256,10 @@ def fit(self, X, y, sample_weight=None):
253256
self.data_type_ = type(X)
254257
return self
255258

256-
X, y = datasets.make_classification()
259+
X, y = datasets.make_multilabel_classification(n_classes=1,
260+
return_indicator=True)
261+
# Flatten y to a 1d array
262+
y = np.ravel(y)
257263

258264
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
259265

@@ -297,7 +303,9 @@ def fit(self, X, y, sample_weight=None):
297303
self.data_type_ = type(X)
298304
return self
299305

300-
X, y = datasets.make_regression()
306+
X, y = datasets.make_multilabel_classification(n_classes=20,
307+
return_indicator=True)
308+
y = y.sum(axis=1)
301309

302310
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
303311

0 commit comments

Comments
 (0)