diff --git a/README.rst b/README.rst index 1815a48d50f61cb14d65ac75421ba9831f72036a..154472c45f9f99d380e11d3d964adeeed4c7fe9b 100644 --- a/README.rst +++ b/README.rst @@ -25,9 +25,7 @@ Dependencies ============ The required dependencies to build the software are python >= 2.5, -setuptools, NumPy >= 1.1, SciPy >= 0.6 (although having at least 0.7 -is highly recommended and required by some modules) and a working C++ -compiler. +setuptools, NumPy >= 1.2, SciPy >= 0.7 and a working C++ compiler. To run the tests you will also need nose >= 0.10. diff --git a/scikits/learn/__init__.py b/scikits/learn/__init__.py index 0684bcf0bdef40bc8ac464f32f534b9ce8d14b1a..4638dbb41f42ec15db2a55c41b29f2a2e88e82bc 100644 --- a/scikits/learn/__init__.py +++ b/scikits/learn/__init__.py @@ -42,4 +42,4 @@ __all__ = ['cross_val', 'ball_tree', 'cluster', 'covariance', 'datasets', 'pca', 'pipeline', 'preprocessing', 'qda', 'svm', 'test', 'clone'] -__version__ = '0.7' +__version__ = '0.7.1' diff --git a/scikits/learn/linear_model/ridge.py b/scikits/learn/linear_model/ridge.py index 4dc849efb0fe65cef9534cf63e4e27f860f625ca..36a9e50e56b33e083bfdb9c9bc0c81f91e2e1c96 100644 --- a/scikits/learn/linear_model/ridge.py +++ b/scikits/learn/linear_model/ridge.py @@ -6,9 +6,6 @@ Ridge regression # License: Simplified BSD import numpy as np -import scipy.sparse as sp -from scipy import linalg -from scipy.sparse import linalg as sp_linalg from .base import LinearModel from ..utils.extmath import safe_sparse_dot @@ -85,6 +82,7 @@ class Ridge(LinearModel): X, y, Xmean, ymean = \ LinearModel._center_data(X, y, self.fit_intercept) + import scipy.sparse as sp if sp.issparse(X): self._solve_sparse(X, y, sample_weight) else: @@ -116,6 +114,7 @@ class Ridge(LinearModel): def _solve_sparse(self, X, y, sample_weight): n_samples, n_features = X.shape + import scipy.sparse as sp if n_features > n_samples or \ isinstance(sample_weight, np.ndarray) or \ sample_weight != 1.0: @@ -132,14 +131,17 @@ class Ridge(LinearModel): def _solve(self, A, b): if self.solver == "cg": # this solver cannot handle a 2-d b. + from scipy.sparse import linalg as sp_linalg sol, error = sp_linalg.cg(A, b) if error: raise ValueError("Failed with error code %d" % error) return sol else: + import scipy.sparse as sp # we are working with dense symmetric positive A if sp.issparse(A): A = A.todense() + from scipy import linalg return linalg.solve(A, b, sym_pos=True, overwrite_a=True) @@ -255,6 +257,7 @@ class _RidgeGCV(LinearModel): def _pre_compute(self, X, y): # even if X is very sparse, K is usually very dense K = safe_sparse_dot(X, X.T, dense_output=True) + from scipy import linalg v, Q = linalg.eigh(K) return K, v, Q diff --git a/scikits/learn/linear_model/tests/test_least_angle.py b/scikits/learn/linear_model/tests/test_least_angle.py index 4521dbbab5931b3c784856e4e40485f06611ba97..022905793fd70517a94151296e73d4b1d6fe774d 100644 --- a/scikits/learn/linear_model/tests/test_least_angle.py +++ b/scikits/learn/linear_model/tests/test_least_angle.py @@ -1,5 +1,5 @@ import numpy as np -from numpy.testing import assert_, assert_array_almost_equal +from numpy.testing import assert_array_almost_equal from scikits.learn import linear_model, datasets @@ -84,7 +84,7 @@ def test_collinearity(): y = np.array([1., 0., 0]) _, _, coef_path_ = linear_model.lars_path(X, y) - assert_(not np.isnan(coef_path_).any()) + assert (not np.isnan(coef_path_).any()) assert_array_almost_equal(np.dot(X, coef_path_[:,-1]), y) diff --git a/scikits/learn/tests/test_neighbors.py b/scikits/learn/tests/test_neighbors.py index 3921fadf6b74c090b2f8610915eb18784a8f0815..79577a3ea651a84193c4c23cb74fdc92e0fb2215 100644 --- a/scikits/learn/tests/test_neighbors.py +++ b/scikits/learn/tests/test_neighbors.py @@ -1,6 +1,5 @@ import numpy as np -from numpy.testing import assert_array_almost_equal, assert_array_equal, \ - assert_ +from numpy.testing import assert_array_almost_equal, assert_array_equal from scikits.learn import neighbors, datasets @@ -58,13 +57,13 @@ def test_neighbors_iris(): assert_array_equal(clf.predict(iris.data), iris.target) clf.fit(iris.data, iris.target, n_neighbors=9, algorithm=s) - assert_(np.mean(clf.predict(iris.data)== iris.target) > 0.95) + assert np.mean(clf.predict(iris.data)== iris.target) > 0.95 for m in ('barycenter', 'mean'): rgs = neighbors.NeighborsRegressor() rgs.fit(iris.data, iris.target, mode=m, algorithm=s) - assert_(np.mean( - rgs.predict(iris.data).round() == iris.target) > 0.95) + assert np.mean( + rgs.predict(iris.data).round() == iris.target) > 0.95 def test_kneighbors_graph(): diff --git a/setup.py b/setup.py index b50445f3b2ad26cdd66488b6e94eba2f2d6c947d..9d2a4039d13337fc3c618e3d20f6fe26588846ba 100644 --- a/setup.py +++ b/setup.py @@ -9,13 +9,13 @@ import os DISTNAME = 'scikits.learn' DESCRIPTION = 'A set of python modules for machine learning and data mining' -LONG_DESCRIPTION = descr +LONG_DESCRIPTION = open('README.rst').read() MAINTAINER = 'Fabian Pedregosa' MAINTAINER_EMAIL = 'fabian.pedregosa@inria.fr' URL = 'http://scikit-learn.sourceforge.net' LICENSE = 'new BSD' DOWNLOAD_URL = 'http://sourceforge.net/projects/scikit-learn/files/' -VERSION = '0.7' +VERSION = '0.7.1' import setuptools # we are using a setuptools namespace from numpy.distutils.core import setup