Skip to content

Commit

Permalink
MAINT first step towards sklearn==0.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mfeurer committed Apr 7, 2016
1 parent 22b925f commit db611bd
Show file tree
Hide file tree
Showing 25 changed files with 49 additions and 50 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ env:
- TEST_DIR=/tmp/test_dir/
- MODULE=autosklearn
matrix:
- DISTRIB="conda" PYTHON_VERSION="2.7" NUMPY_VERSION="1.9" SCIPY_VERSION="0.17"
- DISTRIB="conda" PYTHON_VERSION="3.4" COVERAGE="true" NUMPY_VERSION="1.9" SCIPY_VERSION="0.17"
- DISTRIB="conda" PYTHON_VERSION="2.7"
- DISTRIB="conda" PYTHON_VERSION="3.4" COVERAGE="true"

install:
# Necessary for random forest
Expand Down
9 changes: 4 additions & 5 deletions autosklearn/pipeline/components/classification/lda.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, shrinkage, n_components, tol, shrinkage_factor=0.5,
self.estimator = None

def fit(self, X, Y):
import sklearn.lda
import sklearn.discriminant_analysis
import sklearn.multiclass

if self.shrinkage == "None":
Expand All @@ -36,10 +36,9 @@ def fit(self, X, Y):
self.n_components = int(self.n_components)
self.tol = float(self.tol)

estimator = sklearn.lda.LDA(n_components=self.n_components,
shrinkage=self.shrinkage,
tol=self.tol,
solver=solver)
estimator = sklearn.discriminant_analysis.LinearDiscriminantAnalysis(
n_components=self.n_components, shrinkage=self.shrinkage,
tol=self.tol, solver=solver)

if len(Y.shape) == 2 and Y.shape[1] > 1:
self.estimator = sklearn.multiclass.OneVsRestClassifier(estimator, n_jobs=1)
Expand Down
4 changes: 2 additions & 2 deletions autosklearn/pipeline/components/classification/qda.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def __init__(self, reg_param, random_state=None):
self.estimator = None

def fit(self, X, Y):
import sklearn.qda
import sklearn.discriminant_analysis

estimator = sklearn.qda.QDA(self.reg_param)
estimator = sklearn.discriminant_analysis.QuadraticDiscriminantAnalysis(self.reg_param)

if len(Y.shape) == 2 and Y.shape[1] > 1:
self.estimator = sklearn.multiclass.OneVsRestClassifier(estimator, n_jobs=1)
Expand Down
2 changes: 1 addition & 1 deletion autosklearn/pipeline/components/regression/adaboost.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def fit(self, X, Y):
self.n_estimators = int(self.n_estimators)
self.learning_rate = float(self.learning_rate)
self.max_depth = int(self.max_depth)
base_estimator = sklearn.tree.DecisionTreeClassifier(
base_estimator = sklearn.tree.DecisionTreeRegressor(
max_depth=self.max_depth)

self.estimator = sklearn.ensemble.AdaBoostRegressor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def fit(self, X, Y):
optimizer='Welch',
random_state=self.random_state)
self.scaler = sklearn.preprocessing.StandardScaler(copy=True)
self.scaler.fit(Y)
Y_scaled = self.scaler.transform(Y)
self.scaler.fit(Y.reshape((-1, 1)))
Y_scaled = self.scaler.transform(Y.reshape((-1, 1))).ravel()
self.estimator.fit(X, Y_scaled)
return self

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ConfigSpace.configuration_space import ConfigurationSpace
from ConfigSpace.hyperparameters import CategoricalHyperparameter, \
Constant, UniformIntegerHyperparameter
UniformIntegerHyperparameter

from autosklearn.pipeline.components.base import AutoSklearnRegressionAlgorithm
from autosklearn.pipeline.constants import *
Expand All @@ -17,7 +17,7 @@ def fit(self, X, Y):
import sklearn.neighbors

self.estimator = \
sklearn.neighbors.KNeighborsClassifier(
sklearn.neighbors.KNeighborsRegressor(
n_neighbors=self.n_neighbors,
weights=self.weights,
p=self.p)
Expand Down
4 changes: 2 additions & 2 deletions autosklearn/pipeline/components/regression/libsvm_svr.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def fit(self, X, Y):
)
self.scaler = sklearn.preprocessing.StandardScaler(copy=True)

self.scaler.fit(Y)
Y_scaled = self.scaler.transform(Y)
self.scaler.fit(Y.reshape((-1, 1)))
Y_scaled = self.scaler.transform(Y.reshape((-1, 1))).ravel()
self.estimator.fit(X, Y_scaled)
return self

Expand Down
4 changes: 2 additions & 2 deletions autosklearn/pipeline/components/regression/sgd.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def iterative_fit(self, X, y, n_iter=1, refit=False):
random_state=self.random_state)

self.scaler = sklearn.preprocessing.StandardScaler(copy=True)
self.scaler.fit(y)
self.scaler.fit(y.reshape((-1, 1)))

Y_scaled = self.scaler.transform(y)
Y_scaled = self.scaler.transform(y.reshape((-1, 1))).ravel()

self.estimator.n_iter = n_iter
self._iterations += n_iter
Expand Down
1 change: 0 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ dependencies:
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 10
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20
- sudo update-alternatives --install /usr/bin/x86_64-linux-gnu-gcc x86_64-linux-gnu-gcc /usr/bin/g++-4.9 20
# from scikit-learn contrib
- sudo -E apt-get -yq remove texlive-binaries --purge
- sudo apt-get update
Expand Down
2 changes: 1 addition & 1 deletion requ.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ nose
numpy>=1.9.0
scipy>=0.14.1

scikit-learn==0.16.1
scikit-learn==0.17.1

lockfile
joblib
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
packages=setuptools.find_packages(exclude=['test']),
install_requires=['numpy>=1.9.0',
'scipy>=0.14.1',
'scikit-learn==0.16.1',
'scikit-learn==0.17.1',
'lockfile',
'psutil',
'pyyaml',
Expand Down
10 changes: 5 additions & 5 deletions test/test_pipeline/components/classification/test_adaboost.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ def test_default_configuration_iris_predict_proba(self):
for i in range(10):
predictions, targets = \
_test_classifier_predict_proba(AdaboostClassifier)
self.assertAlmostEqual(0.34244204343758322,
self.assertAlmostEqual(0.22452300738472031,
sklearn.metrics.log_loss(targets, predictions))

def test_default_configuration_iris_sparse(self):
for i in range(10):
predictions, targets = \
_test_classifier(AdaboostClassifier, sparse=True)
self.assertAlmostEqual(0.88,
self.assertAlmostEqual(0.85999999999999999,
sklearn.metrics.accuracy_score(targets,
predictions))

Expand All @@ -39,7 +39,7 @@ def test_default_configuration_multilabel(self):
_test_classifier(classifier=AdaboostClassifier,
dataset='digits',
make_multilabel=True)
self.assertAlmostEqual(0.80933874118770355,
self.assertAlmostEqual(0.79529966660329099,
sklearn.metrics.average_precision_score(
targets, predictions))

Expand All @@ -49,7 +49,7 @@ def test_default_configuration_multilabel_predict_proba(self):
_test_classifier_predict_proba(classifier=AdaboostClassifier,
make_multilabel=True)
self.assertEqual(predictions.shape, ((50, 3)))
self.assertAlmostEqual(0.97856971820815897,
self.assertAlmostEqual(0.9722131915406923,
sklearn.metrics.average_precision_score(
targets, predictions))

Expand All @@ -59,7 +59,7 @@ def test_default_configuration_binary(self):
_test_classifier(classifier=AdaboostClassifier,
dataset='digits', sparse=True,
make_binary=True)
self.assertAlmostEqual(0.93199757134183359,
self.assertAlmostEqual(0.93564055859137829,
sklearn.metrics.accuracy_score(
targets, predictions))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_default_configuration_multilabel(self):
_test_classifier(classifier=GaussianNB,
dataset='digits',
make_multilabel=True)
self.assertAlmostEqual(0.70602999913720499,
self.assertAlmostEqual(0.71507312748717466,
sklearn.metrics.average_precision_score(
targets, predictions))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_default_configuration_multilabel(self):
_test_classifier(classifier=GradientBoostingClassifier,
dataset='digits',
make_multilabel=True)
self.assertAlmostEqual(0.83835860291198527,
self.assertAlmostEqual(0.84004577632243804,
sklearn.metrics.average_precision_score(
targets, predictions))

Expand Down
4 changes: 2 additions & 2 deletions test/test_pipeline/components/classification/test_lda.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np
import sklearn.metrics
import sklearn.lda
import sklearn.discriminant_analysis


class LDAComponentTest(unittest.TestCase):
Expand Down Expand Up @@ -53,7 +53,7 @@ def test_default_configuration_predict_proba_multilabel(self):
targets, predictions))

def test_target_algorithm_multioutput_multiclass_support(self):
cls = sklearn.lda.LDA()
cls = sklearn.discriminant_analysis.LinearDiscriminantAnalysis()
X = np.random.random((10, 10))
y = np.random.randint(0, 1, size=(10, 10))
self.assertRaisesRegexp(ValueError, 'bad input shape \(10, 10\)',
Expand Down
4 changes: 2 additions & 2 deletions test/test_pipeline/components/classification/test_qda.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np
import sklearn.metrics
import sklearn.qda
import sklearn.discriminant_analysis


class QDAComponentTest(unittest.TestCase):
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_default_configuration_predict_proba_multilabel(self):
targets, predictions))

def test_target_algorithm_multioutput_multiclass_support(self):
cls = sklearn.qda.QDA()
cls = sklearn.discriminant_analysis.QuadraticDiscriminantAnalysis()
X = np.random.random((10, 10))
y = np.random.randint(0, 1, size=(10, 10))
self.assertRaisesRegexp(ValueError, 'bad input shape \(10, 10\)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ def test_weighting_effect(self):
random_state=1)

for name, clf, acc_no_weighting, acc_weighting in \
[('adaboost', AdaboostClassifier, 0.709, 0.662),
('decision_tree', DecisionTree, 0.683, 0.726),
('extra_trees', ExtraTreesClassifier, 0.812, 0.812),
[('adaboost', AdaboostClassifier, 0.709, 0.658),
('decision_tree', DecisionTree, 0.683, 0.701),
('extra_trees', ExtraTreesClassifier, 0.812, 0.8),
('gradient_boosting', GradientBoostingClassifier,
0.800, 0.760),
('random_forest', RandomForest, 0.849, 0.780),
('random_forest', RandomForest, 0.846, 0.792),
('libsvm_svc', LibSVM_SVC, 0.571, 0.658),
('liblinear_svc', LibLinear_SVC, 0.685, 0.699),
('sgd', SGD, 0.65384615384615385, 0.38795986622073581)]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_default_configuration_regression(self):
predictor = regressor.fit(X_train_trans, Y_train)
predictions = predictor.predict(X_test_trans)
accuracy = sklearn.metrics.mean_squared_error(predictions, Y_test)
self.assertAlmostEqual(accuracy, 19.812321348314608, places=2)
self.assertAlmostEqual(accuracy, 20.193400000000004, places=2)

def test_default_configuration_classify_sparse(self):
for i in range(2):
Expand All @@ -56,7 +56,7 @@ def test_default_configuration_classify_sparse(self):
predictor = regressor.fit(X_train_trans, Y_train)
predictions = predictor.predict(X_test_trans)
accuracy = sklearn.metrics.mean_squared_error(predictions, Y_test)
self.assertAlmostEqual(accuracy, 62.741933389903252, places=2)
self.assertAlmostEqual(accuracy, 62.485374939528718, places=2)

def test_preprocessing_dtype(self):
super(ExtreTreesRegressionComponentTest, self).\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_default_configuration_classify(self):
predictor = classifier.fit(X_train_trans, Y_train)
predictions = predictor.predict(X_test_trans)
accuracy = sklearn.metrics.accuracy_score(predictions, Y_test)
self.assertAlmostEqual(accuracy, 0.8026715)
self.assertAlmostEqual(accuracy, 0.81056466302367947)

def test_preprocessing_dtype(self):
super(FeatureAgglomerationComponentTest,
Expand Down
4 changes: 2 additions & 2 deletions test/test_pipeline/components/regression/test_adaboost.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ def test_default_configuration(self):
for i in range(10):
predictions, targets = \
_test_regressor(AdaboostRegressor, dataset='boston')
self.assertAlmostEqual(0.11053868761882502,
self.assertAlmostEqual(0.53163164558327014,
sklearn.metrics.r2_score(targets,
predictions))

def test_default_configuration_sparse(self):
for i in range(10):
predictions, targets = \
_test_regressor(AdaboostRegressor, sparse=True, dataset='boston')
self.assertAlmostEqual(-0.077540100211211049,
self.assertAlmostEqual(0.22163148231037866,
sklearn.metrics.r2_score(targets,
predictions))
6 changes: 3 additions & 3 deletions test/test_pipeline/components/regression/test_extra_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ def test_default_configuration(self):
for i in range(10):
predictions, targets = \
_test_regressor(ExtraTreesRegressor)
self.assertAlmostEqual(0.4269923975466271,
self.assertAlmostEqual(0.42779639951661386,
sklearn.metrics.r2_score(targets,
predictions))

def test_default_configuration_sparse(self):
for i in range(10):
predictions, targets = \
_test_regressor(ExtraTreesRegressor, sparse=True)
self.assertAlmostEqual(0.26287621251507987,
self.assertAlmostEqual(0.26270282847272175,
sklearn.metrics.r2_score(targets,
predictions))

def test_default_configuration_iterative_fit(self):
for i in range(10):
predictions, targets = \
_test_regressor_iterative_fit(ExtraTreesRegressor)
self.assertAlmostEqual(0.4269923975466271,
self.assertAlmostEqual(0.42779639951661386,
sklearn.metrics.r2_score(targets,
predictions))
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

class GaussianProcessComponentTest(unittest.TestCase):
def test_default_configuration(self):
for i in range(10):
# Only twice to reduce the number of warning printed to the command line
for i in range(2):
# Float32 leads to numeric instabilities
predictions, targets = _test_regressor(GaussianProcess,
dataset='boston')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def test_default_configuration(self):
for i in range(10):
predictions, targets = _test_regressor(LibLinear_SVR,
dataset='boston')
self.assertAlmostEqual(0.54372712745256768,
self.assertAlmostEqual(0.67714499792824023,
sklearn.metrics.r2_score(y_true=targets,
y_pred=predictions))
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ def test_default_configuration(self):
for i in range(10):

predictions, targets = _test_regressor(RandomForest)
self.assertAlmostEqual(0.41224692924630502,
self.assertAlmostEqual(0.40965687834764064,
sklearn.metrics.r2_score(y_true=targets, y_pred=predictions))


def test_default_configuration_sparse(self):
for i in range(10):
predictions, targets = _test_regressor(RandomForest, sparse=True)
self.assertAlmostEqual(0.24117530425422551,
self.assertAlmostEqual(0.24147637508106434,
sklearn.metrics.r2_score(y_true=targets, y_pred=predictions))

def test_default_configuration_iterative_fit(self):
for i in range(10):
predictions, targets = \
_test_regressor_iterative_fit(RandomForest)
self.assertAlmostEqual(0.41224692924630502,
self.assertAlmostEqual(0.40965687834764064,
sklearn.metrics.r2_score(y_true=targets, y_pred=predictions))
2 changes: 1 addition & 1 deletion test/test_pipeline/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def test_default_configuration(self):
predictions = auto.predict(copy.deepcopy(X_test))
# The lower the worse
r2_score = sklearn.metrics.r2_score(Y_test, predictions)
self.assertAlmostEqual(0.41626416529791199, r2_score)
self.assertAlmostEqual(0.41732302035060087, r2_score)
model_score = auto.score(copy.deepcopy(X_test), Y_test)
self.assertEqual(model_score, r2_score)

Expand Down

0 comments on commit db611bd

Please sign in to comment.