From 20006d0611c941e02af980581a1143ce26e73422 Mon Sep 17 00:00:00 2001 From: Fabian Pedregosa <fabian.pedregosa@inria.fr> Date: Wed, 26 May 2010 12:10:36 +0200 Subject: [PATCH] Refactoring: Squash samples_generator module into one file. --- examples/glm/{ols.py => plot_ols.py} | 0 .../nonlinear.py => samples_generator.py} | 27 ++++++++++++++++++- .../datasets/samples_generator/__init__.py | 0 .../datasets/samples_generator/linear.py | 27 ------------------- scikits/learn/datasets/setup.py | 1 - 5 files changed, 26 insertions(+), 29 deletions(-) rename examples/glm/{ols.py => plot_ols.py} (100%) rename scikits/learn/datasets/{samples_generator/nonlinear.py => samples_generator.py} (52%) mode change 100755 => 100644 delete mode 100644 scikits/learn/datasets/samples_generator/__init__.py delete mode 100755 scikits/learn/datasets/samples_generator/linear.py diff --git a/examples/glm/ols.py b/examples/glm/plot_ols.py similarity index 100% rename from examples/glm/ols.py rename to examples/glm/plot_ols.py diff --git a/scikits/learn/datasets/samples_generator/nonlinear.py b/scikits/learn/datasets/samples_generator.py old mode 100755 new mode 100644 similarity index 52% rename from scikits/learn/datasets/samples_generator/nonlinear.py rename to scikits/learn/datasets/samples_generator.py index db44141562..11628fac83 --- a/scikits/learn/datasets/samples_generator/nonlinear.py +++ b/scikits/learn/datasets/samples_generator.py @@ -1,6 +1,32 @@ import numpy as np import numpy.random as nr +def sparse_uncorrelated(nb_samples=100, nb_features=10): + """ + Function creating simulated data with sparse uncorrelated design. + (cf.Celeux et al. 2009, Bayesian regularization in regression) + X = NR.normal(0,1) + Y = NR.normal(X[:,0]+2*X[:,1]-2*X[:,2]-1.5*X[:,3]) + The number of features is at least 10. + + Parameters + ---------- + nb_samples : int + number of samples (defaut is 100). + nb_features : int + number of features (defaut is 5). + + Returns + ------- + X : numpy array of shape (nb_samples, nb_features) for input samples + Y : numpy array of shape (nb_samples) for labels + """ + X = nr.normal(loc=0, scale=1, size=(nb_samples, nb_features)) + Y = nr.normal(loc=X[:, 0] + 2 * X[:, 1] - 2 * X[:,2] - 1.5 * X[:, 3], + scale = np.ones(nb_samples)) + return X, Y + + def friedman(nb_samples=100, nb_features=10,noise_std=1): """ Function creating simulated data with non linearities @@ -27,4 +53,3 @@ def friedman(nb_samples=100, nb_features=10,noise_std=1): Y = 10*np.sin(X[:,0]*X[:,1]) + 20*(X[:,2]-0.5)**2 + 10*X[:,3] + 5*X[:,4] Y += noise_std*nr.normal(loc=0,scale=1,size=(nb_samples)) return X,Y - diff --git a/scikits/learn/datasets/samples_generator/__init__.py b/scikits/learn/datasets/samples_generator/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/scikits/learn/datasets/samples_generator/linear.py b/scikits/learn/datasets/samples_generator/linear.py deleted file mode 100755 index 8492442812..0000000000 --- a/scikits/learn/datasets/samples_generator/linear.py +++ /dev/null @@ -1,27 +0,0 @@ -import numpy as np -import numpy.random as nr - -def sparse_uncorrelated(nb_samples=100, nb_features=10): - """ - Function creating simulated data with sparse uncorrelated design. - (cf.Celeux et al. 2009, Bayesian regularization in regression) - X = NR.normal(0,1) - Y = NR.normal(X[:,0]+2*X[:,1]-2*X[:,2]-1.5*X[:,3]) - The number of features is at least 10. - - Parameters - ---------- - nb_samples : int - number of samples (defaut is 100). - nb_features : int - number of features (defaut is 5). - - Returns - ------- - X : numpy array of shape (nb_samples, nb_features) for input samples - Y : numpy array of shape (nb_samples) for labels - """ - X = nr.normal(loc=0, scale=1, size=(nb_samples, nb_features)) - Y = nr.normal(loc=X[:, 0] + 2 * X[:, 1] - 2 * X[:,2] - 1.5 * X[:, 3], - scale = np.ones(nb_samples)) - return X, Y diff --git a/scikits/learn/datasets/setup.py b/scikits/learn/datasets/setup.py index 579b3fb084..e97f6bd648 100755 --- a/scikits/learn/datasets/setup.py +++ b/scikits/learn/datasets/setup.py @@ -3,7 +3,6 @@ def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('datasets',parent_package,top_path) - config.add_subpackage('samples_generator') config.add_data_dir('data') config.add_data_dir('descr') return config -- GitLab