diff --git a/sklearn/cluster/bicluster.py b/sklearn/cluster/bicluster.py index 8f6206f9599d08f235123cd4f473dc7ae9b5477d..6d5b6e76ee658e32be5b4efcd17bb8781d997b3f 100644 --- a/sklearn/cluster/bicluster.py +++ b/sklearn/cluster/bicluster.py @@ -236,9 +236,11 @@ class SpectralCoclustering(BaseSpectral): (n_cpus + 1 + n_jobs) are used. Thus for n_jobs = -2, all CPUs but one are used. - random_state : int seed, RandomState instance, or None (default) - A pseudo random number generator used by the K-Means - initialization. + random_state : int, RandomState instance or None, optional, default: None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Attributes ---------- @@ -366,9 +368,11 @@ class SpectralBiclustering(BaseSpectral): (n_cpus + 1 + n_jobs) are used. Thus for n_jobs = -2, all CPUs but one are used. - random_state : int seed, RandomState instance, or None (default) - A pseudo random number generator used by the K-Means - initialization. + random_state : int, RandomState instance or None, optional, default: None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Attributes ---------- diff --git a/sklearn/cluster/k_means_.py b/sklearn/cluster/k_means_.py index f33b3f65b714ed8c00ab4f51c4a14e5627b79afd..680edc2672a71e581671d693e8a773ed7de8a2f0 100644 --- a/sklearn/cluster/k_means_.py +++ b/sklearn/cluster/k_means_.py @@ -230,10 +230,11 @@ def k_means(X, n_clusters, init='k-means++', precompute_distances='auto', verbose : boolean, optional Verbosity mode. - random_state : integer or numpy.RandomState, optional - The generator used to initialize the centers. If an integer is - given, it fixes the seed. Defaults to the global numpy random - number generator. + random_state : int, RandomState instance or None, optional, default: None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. copy_x : boolean, optional When pre-computing distances it is more numerically accurate to center @@ -449,10 +450,11 @@ def _kmeans_single_lloyd(X, n_clusters, max_iter=300, init='k-means++', precompute_distances : boolean, default: True Precompute distances (faster but takes more memory). - random_state : integer or numpy.RandomState, optional - The generator used to initialize the centers. If an integer is - given, it fixes the seed. Defaults to the global numpy random - number generator. + random_state : int, RandomState instance or None, optional, default: None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Returns ------- @@ -638,10 +640,11 @@ def _init_centroids(X, k, init, random_state=None, x_squared_norms=None, init : {'k-means++', 'random' or ndarray or callable} optional Method for initialization - random_state : integer or numpy.RandomState, optional - The generator used to initialize the centers. If an integer is - given, it fixes the seed. Defaults to the global numpy random - number generator. + random_state : int, RandomState instance or None, optional, default: None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. x_squared_norms : array, shape (n_samples,), optional Squared euclidean norm of each data point. Pass it if you have it at @@ -766,10 +769,11 @@ class KMeans(BaseEstimator, ClusterMixin, TransformerMixin): (n_cpus + 1 + n_jobs) are used. Thus for n_jobs = -2, all CPUs but one are used. - random_state : integer or numpy.RandomState, optional - The generator used to initialize the centers. If an integer is - given, it fixes the seed. Defaults to the global numpy random - number generator. + random_state : int, RandomState instance or None, optional, default: None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. verbose : int, default 0 Verbosity mode. @@ -1008,10 +1012,11 @@ def _mini_batch_step(X, x_squared_norms, centers, counts, the distances of each sample to its closest center. May not be None when random_reassign is True. - random_state : integer or numpy.RandomState, optional - The generator used to initialize the centers. If an integer is - given, it fixes the seed. Defaults to the global numpy random - number generator. + random_state : int, RandomState instance or None, optional, default: None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. random_reassign : boolean, optional If True, centers with very low counts are randomly reassigned @@ -1247,10 +1252,11 @@ class MiniBatchKMeans(KMeans): Compute label assignment and inertia for the complete dataset once the minibatch optimization has converged in fit. - random_state : integer or numpy.RandomState, optional - The generator used to initialize the centers. If an integer is - given, it fixes the seed. Defaults to the global numpy random - number generator. + random_state : int, RandomState instance or None, optional, default: None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. reassignment_ratio : float, default: 0.01 Control the fraction of the maximum number of counts for a diff --git a/sklearn/cluster/mean_shift_.py b/sklearn/cluster/mean_shift_.py index 2d554c05ff80cd2f107cc8f2719070d59fa627e7..522e034a60e5fa5172d9c6481b616843925abef3 100644 --- a/sklearn/cluster/mean_shift_.py +++ b/sklearn/cluster/mean_shift_.py @@ -47,8 +47,11 @@ def estimate_bandwidth(X, quantile=0.3, n_samples=None, random_state=0, n_samples : int, optional The number of samples to use. If not given, all samples are used. - random_state : int or RandomState - Pseudo-random number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. n_jobs : int, optional (default = 1) The number of parallel jobs to run for neighbors search. diff --git a/sklearn/cluster/spectral.py b/sklearn/cluster/spectral.py index 8b64ca9a6dd1263a4de16e8bbe7162b731397aa5..b3526622a718cde0c966a9065b16b107edd06e18 100644 --- a/sklearn/cluster/spectral.py +++ b/sklearn/cluster/spectral.py @@ -39,9 +39,11 @@ def discretize(vectors, copy=True, max_svd_restarts=30, n_iter_max=20, Maximum number of iterations to attempt in rotation and partition matrix search if machine precision convergence is not reached - random_state : int seed, RandomState instance, or None (default) - A pseudo random number generator used for the initialization of the - of the rotation matrix + random_state : int, RandomState instance or None, optional, default: None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Returns ------- @@ -194,10 +196,13 @@ def spectral_clustering(affinity, n_clusters=8, n_components=None, to be installed. It can be faster on very large, sparse problems, but may also lead to instabilities - random_state : int seed, RandomState instance, or None (default) - A pseudo random number generator used for the initialization - of the lobpcg eigen vectors decomposition when eigen_solver == 'amg' - and by the K-Means initialization. + random_state : int, RandomState instance or None, optional, default: None + A pseudo random number generator used for the initialization of the + lobpcg eigen vectors decomposition when eigen_solver == 'amg' and by + the K-Means initialization. If int, random_state is the seed used by + the random number generator; If RandomState instance, random_state is + the random number generator; If None, the random number generator is + the RandomState instance used by `np.random`. n_init : int, optional, default: 10 Number of time the k-means algorithm will be run with different @@ -326,10 +331,13 @@ class SpectralClustering(BaseEstimator, ClusterMixin): to be installed. It can be faster on very large, sparse problems, but may also lead to instabilities - random_state : int seed, RandomState instance, or None (default) - A pseudo random number generator used for the initialization - of the lobpcg eigen vectors decomposition when eigen_solver == 'amg' - and by the K-Means initialization. + random_state : int, RandomState instance or None, optional, default: None + A pseudo random number generator used for the initialization of the + lobpcg eigen vectors decomposition when eigen_solver == 'amg' and by + the K-Means initialization. If int, random_state is the seed used by + the random number generator; If RandomState instance, random_state is + the random number generator; If None, the random number generator is + the RandomState instance used by `np.random`. n_init : int, optional, default: 10 Number of time the k-means algorithm will be run with different diff --git a/sklearn/covariance/robust_covariance.py b/sklearn/covariance/robust_covariance.py index 29cbd52e183d3679d2c718ae11bad8c2dc97d544..fdf0225dbdadcf39439784dcaf50c288377a6462 100644 --- a/sklearn/covariance/robust_covariance.py +++ b/sklearn/covariance/robust_covariance.py @@ -55,9 +55,11 @@ def c_step(X, n_support, remaining_iterations=30, initial_estimates=None, verbose : boolean, optional Verbose mode. - random_state : integer or numpy.RandomState, optional - The random generator used. If an integer is given, it fixes the - seed. Defaults to the global numpy random number generator. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. cov_computation_method : callable, default empirical_covariance The function which will be used to compute the covariance. @@ -214,9 +216,11 @@ def select_candidates(X, n_support, n_trials, select=1, n_iter=30, Maximum number of iterations for the c_step procedure. (2 is enough to be close to the final solution. "Never" exceeds 20). - random_state : integer or numpy.RandomState, default None - The random generator used. If an integer is given, it fixes the - seed. Defaults to the global numpy random number generator. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. cov_computation_method : callable, default empirical_covariance The function which will be used to compute the covariance. @@ -311,10 +315,11 @@ def fast_mcd(X, support_fraction=None, value of support_fraction will be used within the algorithm: `[n_sample + n_features + 1] / 2`. - random_state : integer or numpy.RandomState, optional - The generator used to randomly subsample. If an integer is - given, it fixes the seed. Defaults to the global numpy random - number generator. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. cov_computation_method : callable, default empirical_covariance The function which will be used to compute the covariance. @@ -531,9 +536,11 @@ class MinCovDet(EmpiricalCovariance): value of support_fraction will be used within the algorithm: [n_sample + n_features + 1] / 2 - random_state : integer or numpy.RandomState, optional - The random generator used. If an integer is given, it fixes the - seed. Defaults to the global numpy random number generator. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Attributes ---------- diff --git a/sklearn/cross_validation.py b/sklearn/cross_validation.py index ff327a25e49249e748611677aec79da3954ab5b8..d56845637fc48b1983366f3a5b204f2d9bf96efa 100644 --- a/sklearn/cross_validation.py +++ b/sklearn/cross_validation.py @@ -1,4 +1,3 @@ - """ The :mod:`sklearn.cross_validation` module includes utilities for cross- validation and performance evaluation. @@ -297,9 +296,11 @@ class KFold(_BaseKFold): shuffle : boolean, optional Whether to shuffle the data before splitting into batches. - random_state : None, int or RandomState - When shuffle=True, pseudo-random number generator state used for - shuffling. If None, use default numpy RNG for shuffling. + random_state : int, RandomState instance or None, optional, default=None + If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Used when ``shuffle`` == True. Examples -------- @@ -499,9 +500,11 @@ class StratifiedKFold(_BaseKFold): Whether to shuffle each stratification of the data before splitting into batches. - random_state : None, int or RandomState - When shuffle=True, pseudo-random number generator state used for - shuffling. If None, use default numpy RNG for shuffling. + random_state : int, RandomState instance or None, optional, default=None + If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Used when ``shuffle`` == True. Examples -------- @@ -822,8 +825,11 @@ class ShuffleSplit(BaseShuffleSplit): int, represents the absolute number of train samples. If None, the value is automatically set to the complement of the test size. - random_state : int or RandomState - Pseudo-random number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Examples -------- @@ -1031,8 +1037,11 @@ class StratifiedShuffleSplit(BaseShuffleSplit): int, represents the absolute number of train samples. If None, the value is automatically set to the complement of the test size. - random_state : int or RandomState - Pseudo-random number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Examples -------- @@ -1225,8 +1234,11 @@ class LabelShuffleSplit(ShuffleSplit): int, represents the absolute number of train labels. If None, the value is automatically set to the complement of the test size. - random_state : int or RandomState - Pseudo-random number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. """ def __init__(self, labels, n_iter=5, test_size=0.2, train_size=None, @@ -1889,9 +1901,11 @@ def permutation_test_score(estimator, X, y, cv=None, Labels constrain the permutation among groups of samples with a same label. - random_state : RandomState or an int seed (0 by default) - A random number generator instance to define the state of the - random permutations generator. + random_state : int, RandomState instance or None, optional (default=0) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. verbose : integer, optional The verbosity level. @@ -1977,8 +1991,11 @@ def train_test_split(*arrays, **options): int, represents the absolute number of train samples. If None, the value is automatically set to the complement of the test size. - random_state : int or RandomState - Pseudo-random number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. stratify : array-like or None (default is None) If not None, data is split in a stratified fashion, using this as diff --git a/sklearn/datasets/olivetti_faces.py b/sklearn/datasets/olivetti_faces.py index 7dfd4dec1624792ccb1fdb8b38225b11bc95d8f9..ac80d49e937d299e43a70de682355e838d88ebd7 100644 --- a/sklearn/datasets/olivetti_faces.py +++ b/sklearn/datasets/olivetti_faces.py @@ -71,9 +71,11 @@ def fetch_olivetti_faces(data_home=None, shuffle=False, random_state=0, If False, raise a IOError if the data is not locally available instead of trying to download the data from the source site. - random_state : optional, integer or RandomState object - The seed or the random number generator used to shuffle the - data. + random_state : int, RandomState instance or None, optional (default=0) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Returns ------- diff --git a/sklearn/datasets/samples_generator.py b/sklearn/datasets/samples_generator.py index e7f61b3227331b396bafb13ffeddd3cad5960673..7a4543aa2068a4f99fc1864ad7d34b86f95bfc2c 100644 --- a/sklearn/datasets/samples_generator.py +++ b/sklearn/datasets/samples_generator.py @@ -1059,8 +1059,11 @@ def make_sparse_coded_signal(n_samples, n_components, n_features, n_nonzero_coefs : int number of active (non-zero) coefficients in each sample - random_state : int or RandomState instance, optional (default=None) - seed used by the pseudo random number generator + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Returns ------- diff --git a/sklearn/decomposition/dict_learning.py b/sklearn/decomposition/dict_learning.py index baf79544dd172e2f863bde10ae6ca0c027b070d2..154987a6279c4afa874ed418391a63a723e34b15 100644 --- a/sklearn/decomposition/dict_learning.py +++ b/sklearn/decomposition/dict_learning.py @@ -328,8 +328,11 @@ def _update_dict(dictionary, Y, code, verbose=False, return_r2=False, Whether to compute and return the residual sum of squares corresponding to the computed solution. - random_state : int or RandomState - Pseudo number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Returns ------- @@ -434,8 +437,11 @@ def dict_learning(X, n_components, alpha, max_iter=100, tol=1e-8, verbose : Degree of output the procedure will print. - random_state : int or RandomState - Pseudo number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. return_n_iter : bool Whether or not to return the number of iterations. @@ -616,8 +622,11 @@ def dict_learning_online(X, n_components=2, alpha=1, n_iter=100, Number of previous iterations completed on the dictionary used for initialization. - random_state : int or RandomState - Pseudo number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. return_inner_stats : boolean, optional Return the inner statistics A (dictionary covariance) and B @@ -1000,8 +1009,11 @@ class DictionaryLearning(BaseEstimator, SparseCodingMixin): verbose : degree of verbosity of the printed output - random_state : int or RandomState - Pseudo number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Attributes ---------- @@ -1160,8 +1172,11 @@ class MiniBatchDictionaryLearning(BaseEstimator, SparseCodingMixin): shuffle : bool, whether to shuffle the samples before forming batches - random_state : int or RandomState - Pseudo number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Attributes ---------- diff --git a/sklearn/decomposition/factor_analysis.py b/sklearn/decomposition/factor_analysis.py index 16e198164a5cd4037aa0b439fd28d9de3ea22ff7..3326ac197b3af9362b538914a94cb22d0c7ba02f 100644 --- a/sklearn/decomposition/factor_analysis.py +++ b/sklearn/decomposition/factor_analysis.py @@ -88,9 +88,11 @@ class FactorAnalysis(BaseEstimator, TransformerMixin): Number of iterations for the power method. 3 by default. Only used if ``svd_method`` equals 'randomized' - random_state : int or RandomState - Pseudo number generator state used for random sampling. Only used - if ``svd_method`` equals 'randomized' + random_state : int, RandomState instance or None, optional (default=0) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Only used when ``svd_method`` equals 'randomized'. Attributes ---------- diff --git a/sklearn/decomposition/fastica_.py b/sklearn/decomposition/fastica_.py index fbbbbec1b713d2e6e4b8cf430f99b9602a16317e..3cca0b7d6e89ce9b374f2d090554f1e52128bdfd 100644 --- a/sklearn/decomposition/fastica_.py +++ b/sklearn/decomposition/fastica_.py @@ -199,8 +199,11 @@ def fastica(X, n_components=None, algorithm="parallel", whiten=True, Initial un-mixing array of dimension (n.comp,n.comp). If None (default) then an array of normal r.v.'s is used. - random_state : int or RandomState - Pseudo number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. return_X_mean : bool, optional If True, X_mean is returned too. @@ -415,8 +418,11 @@ class FastICA(BaseEstimator, TransformerMixin): w_init : None of an (n_components, n_components) ndarray The mixing matrix to be used to initialize the algorithm. - random_state : int or RandomState - Pseudo number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Attributes ---------- diff --git a/sklearn/decomposition/kernel_pca.py b/sklearn/decomposition/kernel_pca.py index 1fb6b55f43aaaad5ae9482d9507ee034b2edcd43..2bd9a5bbddd88a2cb0724e9b66bf65cd79935895 100644 --- a/sklearn/decomposition/kernel_pca.py +++ b/sklearn/decomposition/kernel_pca.py @@ -74,9 +74,11 @@ class KernelPCA(BaseEstimator, TransformerMixin): When n_components is None, this parameter is ignored and components with zero eigenvalues are removed regardless. - random_state : int seed, RandomState instance, or None, default=None - A pseudo random number generator used for the initialization of the - residuals when eigen_solver == 'arpack'. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Used when ``eigen_solver`` == 'arpack'. .. versionadded:: 0.18 diff --git a/sklearn/decomposition/nmf.py b/sklearn/decomposition/nmf.py index 63026e3ad43bdb224aad1138c4ae664578db4149..522bf150aa253473fa0c2ca3bfdcf3d8d2d3bb41 100644 --- a/sklearn/decomposition/nmf.py +++ b/sklearn/decomposition/nmf.py @@ -268,9 +268,11 @@ def _initialize_nmf(X, n_components, init=None, eps=1e-6, eps : float Truncate all values less then this in output to zero. - random_state : int seed, RandomState instance, or None (default) - Random number generator seed control, used in 'nndsvdar' and - 'random' modes. + random_state : int, RandomState instance or None, optional, default: None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Used when ``random`` == 'nndsvdar' or 'random'. Returns ------- @@ -445,8 +447,11 @@ def _fit_coordinate_descent(X, W, H, tol=1e-4, max_iter=200, l1_reg_W=0, shuffle : boolean, default: False If true, randomize the order of coordinates in the CD solver. - random_state : integer seed, RandomState instance, or None (default) - Random number generator seed control. + random_state : int, RandomState instance or None, optional, default: None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Returns ------- @@ -910,8 +915,11 @@ def non_negative_factorization(X, W=None, H=None, n_components=None, Select whether the regularization affects the components (H), the transformation (W), both or none of them. - random_state : integer seed, RandomState instance, or None (default) - Random number generator seed control. + random_state : int, RandomState instance or None, optional, default: None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. verbose : integer, default: 0 The verbosity level. @@ -1097,8 +1105,11 @@ class NMF(BaseEstimator, TransformerMixin): max_iter : integer, default: 200 Maximum number of iterations before timing out. - random_state : integer seed, RandomState instance, or None (default) - Random number generator seed control. + random_state : int, RandomState instance or None, optional, default: None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. alpha : double, default: 0. Constant that multiplies the regularization terms. Set it to zero to diff --git a/sklearn/decomposition/online_lda.py b/sklearn/decomposition/online_lda.py index 8e0c5bfe6b4151a7eef7532942df52c8a9e5b8ce..d24743b3e78d5c017081ced8a2683c7f6d1981d5 100644 --- a/sklearn/decomposition/online_lda.py +++ b/sklearn/decomposition/online_lda.py @@ -219,8 +219,11 @@ class LatentDirichletAllocation(BaseEstimator, TransformerMixin): verbose : int, optional (default=0) Verbosity level. - random_state : int or RandomState instance or None, optional (default=None) - Pseudo-random number generator seed control. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Attributes ---------- diff --git a/sklearn/decomposition/pca.py b/sklearn/decomposition/pca.py index f7cb01a422645f65ee7d02a5e3e176d835bc523b..eb11d9b0321066c398c722894be678cd7f1a0677 100644 --- a/sklearn/decomposition/pca.py +++ b/sklearn/decomposition/pca.py @@ -183,9 +183,11 @@ class PCA(_BasePCA): .. versionadded:: 0.18.0 - random_state : int or RandomState instance or None (default None) - Pseudo Random Number generator seed control. If None, use the - numpy.random singleton. Used by svd_solver == 'arpack' or 'randomized'. + random_state : int, RandomState instance or None, optional (default None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Used when ``svd_solver`` == 'arpack' or 'randomized'. .. versionadded:: 0.18.0 @@ -601,9 +603,11 @@ class RandomizedPCA(BaseEstimator, TransformerMixin): improve the predictive accuracy of the downstream estimators by making their data respect some hard-wired assumptions. - random_state : int or RandomState instance or None (default) - Pseudo Random Number generator seed control. If None, use the - numpy.random singleton. + random_state : int, RandomState instance or None, optional, default=None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Attributes ---------- diff --git a/sklearn/decomposition/sparse_pca.py b/sklearn/decomposition/sparse_pca.py index e6fde97ccb9de18c38bb6f9543479a37dfb11ca9..23d1163fdc881032ef5b93e7da9706c12dca6cac 100644 --- a/sklearn/decomposition/sparse_pca.py +++ b/sklearn/decomposition/sparse_pca.py @@ -60,8 +60,11 @@ class SparsePCA(BaseEstimator, TransformerMixin): verbose : Degree of verbosity of the printed output. - random_state : int or RandomState - Pseudo number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Attributes ---------- @@ -228,8 +231,11 @@ class MiniBatchSparsePCA(SparsePCA): Lasso solution (linear_model.Lasso). Lars will be faster if the estimated components are sparse. - random_state : int or RandomState - Pseudo number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Attributes ---------- diff --git a/sklearn/decomposition/truncated_svd.py b/sklearn/decomposition/truncated_svd.py index 5d029d1205bd0cdd3dc8cdc7b19a141a58ab951f..7ab20926f9589a7c48313afba32594fa41e6f1e9 100644 --- a/sklearn/decomposition/truncated_svd.py +++ b/sklearn/decomposition/truncated_svd.py @@ -59,9 +59,11 @@ class TruncatedSVD(BaseEstimator, TransformerMixin): The default is larger than the default in `randomized_svd` to handle sparse matrices that may have large slowly decaying spectrum. - random_state : int or RandomState, optional - (Seed for) pseudo-random number generator. If not given, the - numpy.random singleton is used. + random_state : int, RandomState instance or None, optional, default = None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. tol : float, optional Tolerance for ARPACK. 0 means machine precision. Ignored by randomized diff --git a/sklearn/dummy.py b/sklearn/dummy.py index 84d42e7177a0ac0926419bd7dfaa38e9537ed232..90a43791c81b61930f80f339d63f551c26609907 100644 --- a/sklearn/dummy.py +++ b/sklearn/dummy.py @@ -47,8 +47,11 @@ class DummyClassifier(BaseEstimator, ClassifierMixin): Dummy Classifier now supports prior fitting strategy using parameter *prior*. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use. + random_state : int, RandomState instance or None, optional, default=None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. constant : int or str or array of shape = [n_outputs] The explicit constant as predicted by the "constant" strategy. This diff --git a/sklearn/ensemble/base.py b/sklearn/ensemble/base.py index 165124d62428adf917e323ea3a201cc4e2619589..5e9d6e2e1fc3c678cf2522baa9d58b41de001042 100644 --- a/sklearn/ensemble/base.py +++ b/sklearn/ensemble/base.py @@ -29,8 +29,11 @@ def _set_random_states(estimator, random_state=None): Estimator with potential randomness managed by random_state parameters. - random_state : numpy.RandomState or int, optional - Random state used to generate integer values. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Notes ----- diff --git a/sklearn/ensemble/gradient_boosting.py b/sklearn/ensemble/gradient_boosting.py index f5eb1001b2bf51cd862721a7c3b9f0fa8de69713..2c18d338dc71531c5b78d0453da91a71a8e28de0 100644 --- a/sklearn/ensemble/gradient_boosting.py +++ b/sklearn/ensemble/gradient_boosting.py @@ -1767,8 +1767,7 @@ class GradientBoostingRegressor(BaseGradientBoosting, RegressorMixin): warm_start : bool, default: False When set to ``True``, reuse the solution of the previous call to fit and add more estimators to the ensemble, otherwise, just erase the - p -revious solution. + previous solution. random_state : int, RandomState instance or None, optional (default=None) If int, random_state is the seed used by the random number generator; diff --git a/sklearn/feature_extraction/image.py b/sklearn/feature_extraction/image.py index 694c624f11110b912989dfab68469062560da4db..708424cb3f84367fbc8c9178b8734fcc722e7f8e 100644 --- a/sklearn/feature_extraction/image.py +++ b/sklearn/feature_extraction/image.py @@ -319,9 +319,12 @@ def extract_patches_2d(image, patch_size, max_patches=None, random_state=None): between 0 and 1, it is taken to be a proportion of the total number of patches. - random_state : int or RandomState + random_state : int, RandomState instance or None, optional (default=None) Pseudo number generator state used for random sampling to use if - `max_patches` is not None. + `max_patches` is not None. If int, random_state is the seed used by + the random number generator; If RandomState instance, random_state is + the random number generator; If None, the random number generator is + the RandomState instance used by `np.random`. Returns ------- @@ -450,8 +453,11 @@ class PatchExtractor(BaseEstimator): float in (0, 1), it is taken to mean a proportion of the total number of patches. - random_state : int or RandomState - Pseudo number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. """ def __init__(self, patch_size=None, max_patches=None, random_state=None): diff --git a/sklearn/feature_selection/mutual_info_.py b/sklearn/feature_selection/mutual_info_.py index b72e884704c5f7894bfab9ec1fddd8b2541b2131..0637f784c5f95c50cd8302ba696dda36bceccb22 100644 --- a/sklearn/feature_selection/mutual_info_.py +++ b/sklearn/feature_selection/mutual_info_.py @@ -224,9 +224,13 @@ def _estimate_mi(X, y, discrete_features='auto', discrete_target=False, Whether to make a copy of the given data. If set to False, the initial data will be overwritten. - random_state : int seed, RandomState instance or None, default None + random_state : int, RandomState instance or None, optional, default None The seed of the pseudo random number generator for adding small noise - to continuous variables in order to remove repeated values. + to continuous variables in order to remove repeated values. If int, + random_state is the seed used by the random number generator; If + RandomState instance, random_state is the random number generator; If + None, the random number generator is the RandomState instance used by + `np.random`. Returns ------- @@ -327,9 +331,13 @@ def mutual_info_regression(X, y, discrete_features='auto', n_neighbors=3, Whether to make a copy of the given data. If set to False, the initial data will be overwritten. - random_state : int seed, RandomState instance or None, default None + random_state : int, RandomState instance or None, optional, default None The seed of the pseudo random number generator for adding small noise to continuous variables in order to remove repeated values. + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Returns ------- @@ -402,9 +410,13 @@ def mutual_info_classif(X, y, discrete_features='auto', n_neighbors=3, Whether to make a copy of the given data. If set to False, the initial data will be overwritten. - random_state : int seed, RandomState instance or None, default None + random_state : int, RandomState instance or None, optional, default None The seed of the pseudo random number generator for adding small noise - to continuous variables in order to remove repeated values. + to continuous variables in order to remove repeated values. If int, + random_state is the seed used by the random number generator; If + RandomState instance, random_state is the random number generator; If + None, the random number generator is the RandomState instance used by + `np.random`. Returns ------- diff --git a/sklearn/gaussian_process/gaussian_process.py b/sklearn/gaussian_process/gaussian_process.py index 0d1b6d4fffe7bf354ca643c83d9b50419546527a..7adac552a5c1ed0e4c6fd39bcbff8cb8f841bd64 100644 --- a/sklearn/gaussian_process/gaussian_process.py +++ b/sklearn/gaussian_process/gaussian_process.py @@ -169,11 +169,12 @@ class GaussianProcess(BaseEstimator, RegressorMixin): exponential distribution (log-uniform on [thetaL, thetaU]). Default does not use random starting point (random_start = 1). - random_state : integer or numpy.RandomState, optional + random_state : int, RandomState instance or None, optional (default=None) The generator used to shuffle the sequence of coordinates of theta in - the Welch optimizer. If an integer is given, it fixes the seed. - Defaults to the global numpy random number generator. - + the Welch optimizer. If int, random_state is the seed used by the + random number generator; If RandomState instance, random_state is the + random number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Attributes ---------- diff --git a/sklearn/gaussian_process/gpc.py b/sklearn/gaussian_process/gpc.py index bbb1feda98e0711e4fa3179eff3981c2cedde4f5..6f491b376e1dcc21979a3b391f256ceb8de9b1e8 100644 --- a/sklearn/gaussian_process/gpc.py +++ b/sklearn/gaussian_process/gpc.py @@ -106,10 +106,11 @@ class _BinaryGaussianProcessClassifierLaplace(BaseEstimator): which might cause predictions to change if the data is modified externally. - random_state : integer or numpy.RandomState, optional - The generator used to initialize the centers. If an integer is - given, it fixes the seed. Defaults to the global numpy random - number generator. + random_state : int, RandomState instance or None, optional (default: None) + The generator used to initialize the centers. If int, random_state is + the seed used by the random number generator; If RandomState instance, + random_state is the random number generator; If None, the random number + generator is the RandomState instance used by `np.random`. Attributes ---------- @@ -510,10 +511,12 @@ class GaussianProcessClassifier(BaseEstimator, ClassifierMixin): which might cause predictions to change if the data is modified externally. - random_state : integer or numpy.RandomState, optional - The generator used to initialize the centers. If an integer is - given, it fixes the seed. Defaults to the global numpy random - number generator. + random_state : int, RandomState instance or None, optional (default: None) + The generator used to initialize the centers. + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. multi_class : string, default : "one_vs_rest" Specifies how multi-class classification problems are handled. diff --git a/sklearn/gaussian_process/gpr.py b/sklearn/gaussian_process/gpr.py index cbf65a8430bc0a9f822a0286dd1b303a760f5038..4ee8e556c706de9e46660d71f2d17026340b55e0 100644 --- a/sklearn/gaussian_process/gpr.py +++ b/sklearn/gaussian_process/gpr.py @@ -103,10 +103,11 @@ class GaussianProcessRegressor(BaseEstimator, RegressorMixin): which might cause predictions to change if the data is modified externally. - random_state : integer or numpy.RandomState, optional - The generator used to initialize the centers. If an integer is - given, it fixes the seed. Defaults to the global numpy random - number generator. + random_state : int, RandomState instance or None, optional (default: None) + The generator used to initialize the centers. If int, random_state is + the seed used by the random number generator; If RandomState instance, + random_state is the random number generator; If None, the random number + generator is the RandomState instance used by `np.random`. Attributes ---------- @@ -336,8 +337,11 @@ class GaussianProcessRegressor(BaseEstimator, RegressorMixin): n_samples : int, default: 1 The number of samples drawn from the Gaussian process - random_state : RandomState or an int seed (0 by default) - A random number generator instance + random_state : int, RandomState instance or None, optional (default=0) + If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the + random number generator; If None, the random number + generator is the RandomState instance used by `np.random`. Returns ------- diff --git a/sklearn/grid_search.py b/sklearn/grid_search.py index 5bdff14f83a76573945d502948bd857f7c5b2bd8..2f432362e37e44a1edd4eb36a4ff0bbb8fc04b42 100644 --- a/sklearn/grid_search.py +++ b/sklearn/grid_search.py @@ -200,9 +200,13 @@ class ParameterSampler(object): n_iter : integer Number of parameter settings that are produced. - random_state : int or RandomState + random_state : int, RandomState instance or None, optional (default=None) Pseudo random number generator state used for random uniform sampling from lists of possible values instead of scipy.stats distributions. + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Returns ------- @@ -954,9 +958,13 @@ class RandomizedSearchCV(BaseSearchCV): verbose : integer Controls the verbosity: the higher, the more messages. - random_state : int or RandomState + random_state : int, RandomState instance or None, optional, default=None Pseudo random number generator state used for random uniform sampling from lists of possible values instead of scipy.stats distributions. + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. error_score : 'raise' (default) or numeric Value to assign to the score if an error occurs in estimator fitting. diff --git a/sklearn/kernel_approximation.py b/sklearn/kernel_approximation.py index a47016e448c82666d6392df200f5941edb10fa08..3fef755dfdf4e0399e8a2ce9cde277dc99d2868b 100644 --- a/sklearn/kernel_approximation.py +++ b/sklearn/kernel_approximation.py @@ -38,9 +38,11 @@ class RBFSampler(BaseEstimator, TransformerMixin): Number of Monte Carlo samples per original feature. Equals the dimensionality of the computed feature space. - random_state : {int, RandomState}, optional + random_state : int, RandomState instance or None, optional (default=None) If int, random_state is the seed used by the random number generator; - if RandomState instance, random_state is the random number generator. + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Notes ----- @@ -124,9 +126,11 @@ class SkewedChi2Sampler(BaseEstimator, TransformerMixin): number of Monte Carlo samples per original feature. Equals the dimensionality of the computed feature space. - random_state : {int, RandomState}, optional + random_state : int, RandomState instance or None, optional (default=None) If int, random_state is the seed used by the random number generator; - if RandomState instance, random_state is the random number generator. + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. References ---------- @@ -394,10 +398,11 @@ class Nystroem(BaseEstimator, TransformerMixin): Additional parameters (keyword arguments) for kernel function passed as callable object. - random_state : {int, RandomState}, optional + random_state : int, RandomState instance or None, optional (default=None) If int, random_state is the seed used by the random number generator; - if RandomState instance, random_state is the random number generator. - + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Attributes ---------- diff --git a/sklearn/linear_model/coordinate_descent.py b/sklearn/linear_model/coordinate_descent.py index 95cafb29e78e250aa89500475e40ab99d5d73304..a2eb3be475f834ce96ca094bdca5e750ba2e4470 100644 --- a/sklearn/linear_model/coordinate_descent.py +++ b/sklearn/linear_model/coordinate_descent.py @@ -582,9 +582,12 @@ class ElasticNet(LinearModel, RegressorMixin): (setting to 'random') often leads to significantly faster convergence especially when tol is higher than 1e-4. - random_state : int, RandomState instance, or None (default) - The seed of the pseudo random number generator that selects - a random feature to update. Useful only when selection is set to + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator that selects a random + feature to update. If int, random_state is the seed used by the random + number generator; If RandomState instance, random_state is the random + number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Used when ``selection`` == 'random'. Attributes @@ -829,9 +832,12 @@ class Lasso(ElasticNet): (setting to 'random') often leads to significantly faster convergence especially when tol is higher than 1e-4. - random_state : int, RandomState instance, or None (default) - The seed of the pseudo random number generator that selects - a random feature to update. Useful only when selection is set to + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator that selects a random + feature to update. If int, random_state is the seed used by the random + number generator; If RandomState instance, random_state is the random + number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Used when ``selection`` == 'random'. Attributes @@ -1266,9 +1272,12 @@ class LassoCV(LinearModelCV, RegressorMixin): (setting to 'random') often leads to significantly faster convergence especially when tol is higher than 1e-4. - random_state : int, RandomState instance, or None (default) - The seed of the pseudo random number generator that selects - a random feature to update. Useful only when selection is set to + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator that selects a random + feature to update. If int, random_state is the seed used by the random + number generator; If RandomState instance, random_state is the random + number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Used when ``selection`` == 'random'. fit_intercept : boolean, default True @@ -1418,9 +1427,12 @@ class ElasticNetCV(LinearModelCV, RegressorMixin): (setting to 'random') often leads to significantly faster convergence especially when tol is higher than 1e-4. - random_state : int, RandomState instance, or None (default) - The seed of the pseudo random number generator that selects - a random feature to update. Useful only when selection is set to + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator that selects a random + feature to update. If int, random_state is the seed used by the random + number generator; If RandomState instance, random_state is the random + number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Used when ``selection`` == 'random'. fit_intercept : boolean @@ -1588,9 +1600,12 @@ class MultiTaskElasticNet(Lasso): (setting to 'random') often leads to significantly faster convergence especially when tol is higher than 1e-4. - random_state : int, RandomState instance, or None (default) - The seed of the pseudo random number generator that selects - a random feature to update. Useful only when selection is set to + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator that selects a random + feature to update. If int, random_state is the seed used by the random + number generator; If RandomState instance, random_state is the random + number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Used when ``selection`` == 'random'. Attributes @@ -1772,9 +1787,12 @@ class MultiTaskLasso(MultiTaskElasticNet): (setting to 'random') often leads to significantly faster convergence especially when tol is higher than 1e-4 - random_state : int, RandomState instance, or None (default) - The seed of the pseudo random number generator that selects - a random feature to update. Useful only when selection is set to + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator that selects a random + feature to update. If int, random_state is the seed used by the random + number generator; If RandomState instance, random_state is the random + number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Used when ``selection`` == 'random'. Attributes @@ -1925,9 +1943,12 @@ class MultiTaskElasticNetCV(LinearModelCV, RegressorMixin): (setting to 'random') often leads to significantly faster convergence especially when tol is higher than 1e-4. - random_state : int, RandomState instance, or None (default) - The seed of the pseudo random number generator that selects - a random feature to update. Useful only when selection is set to + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator that selects a random + feature to update. If int, random_state is the seed used by the random + number generator; If RandomState instance, random_state is the random + number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Used when ``selection`` == 'random'. Attributes @@ -2089,10 +2110,13 @@ class MultiTaskLassoCV(LinearModelCV, RegressorMixin): (setting to 'random') often leads to significantly faster convergence especially when tol is higher than 1e-4. - random_state : int, RandomState instance, or None (default) - The seed of the pseudo random number generator that selects - a random feature to update. Useful only when selection is set to - 'random'. + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator that selects a random + feature to update. If int, random_state is the seed used by the random + number generator; If RandomState instance, random_state is the random + number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Used when ``selection`` == + 'random'/ Attributes ---------- diff --git a/sklearn/linear_model/logistic.py b/sklearn/linear_model/logistic.py index 196d7f697d0e8a1efde71b3860555e94a0600112..fa7bc7f32e4becfa8aecee5c0d572a002b2e4791 100644 --- a/sklearn/linear_model/logistic.py +++ b/sklearn/linear_model/logistic.py @@ -543,9 +543,13 @@ def logistic_regression_path(X, y, pos_class=None, Cs=10, fit_intercept=True, the entire probability distribution. Works only for the 'lbfgs' and 'newton-cg' solvers. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data. Used only in solvers 'sag' and 'liblinear'. + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Used when ``solver`` == 'sag' or + 'liblinear'. check_input : bool, default True If False, the input arrays X and y will not be checked. @@ -860,9 +864,13 @@ def _log_reg_scoring_path(X, y, train, test, pos_class=None, Cs=10, the entire probability distribution. Does not work for liblinear solver. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data. Used only in solvers 'sag' and 'liblinear'. + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Used when ``solver`` == 'sag' and + 'liblinear'. max_squared_sum : float, default None Maximum squared sum of X over samples. Used only in SAG solver. @@ -1024,9 +1032,13 @@ class LogisticRegression(BaseEstimator, LinearClassifierMixin, Useful only for the newton-cg, sag and lbfgs solvers. Maximum number of iterations taken for the solvers to converge. - random_state : int seed, RandomState instance, default: None - The seed of the pseudo random number generator to use when - shuffling the data. Used only in solvers 'sag' and 'liblinear'. + random_state : int, RandomState instance or None, optional, default: None + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Used when ``solver`` == 'sag' or + 'liblinear'. solver : {'newton-cg', 'lbfgs', 'liblinear', 'sag', 'saga'}, default: 'liblinear' @@ -1470,9 +1482,11 @@ class LogisticRegressionCV(LogisticRegression, BaseEstimator, To lessen the effect of regularization on synthetic feature weight (and therefore on the intercept) intercept_scaling has to be increased. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data. + random_state : int, RandomState instance or None, optional, default None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Attributes ---------- diff --git a/sklearn/linear_model/passive_aggressive.py b/sklearn/linear_model/passive_aggressive.py index 376ca92e934225ee9e3df309abb7557cbccc0df2..941f398bd6e1380376a524d0abca988b04309ca0 100644 --- a/sklearn/linear_model/passive_aggressive.py +++ b/sklearn/linear_model/passive_aggressive.py @@ -28,9 +28,12 @@ class PassiveAggressiveClassifier(BaseSGDClassifier): shuffle : bool, default=True Whether or not the training data should be shuffled after each epoch. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data. + random_state : int, RandomState instance or None, optional, default=None + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. verbose : integer, optional The verbosity level @@ -204,9 +207,12 @@ class PassiveAggressiveRegressor(BaseSGDRegressor): shuffle : bool, default=True Whether or not the training data should be shuffled after each epoch. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data. + random_state : int, RandomState instance or None, optional, default=None + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. verbose : integer, optional The verbosity level diff --git a/sklearn/linear_model/perceptron.py b/sklearn/linear_model/perceptron.py index d5971817650248b72656f017ad317b409db9db9a..0b11049fc3b39f60d680cd4ebc4fe809a304a8b6 100644 --- a/sklearn/linear_model/perceptron.py +++ b/sklearn/linear_model/perceptron.py @@ -30,9 +30,12 @@ class Perceptron(BaseSGDClassifier): shuffle : bool, optional, default True Whether or not the training data should be shuffled after each epoch. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data. + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. verbose : integer, optional The verbosity level diff --git a/sklearn/linear_model/randomized_l1.py b/sklearn/linear_model/randomized_l1.py index 8f8f5c12efe87756f71a13196fba5e53a8cee883..6ebf95d2533ff85dba5ac0478289c09051a6efae 100644 --- a/sklearn/linear_model/randomized_l1.py +++ b/sklearn/linear_model/randomized_l1.py @@ -575,8 +575,11 @@ def lasso_stability_path(X, y, scaling=0.5, random_state=None, The alpha parameter in the stability selection article used to randomly scale the features. Should be between 0 and 1. - random_state : integer or numpy.random.RandomState, optional - The generator used to randomize the design. + random_state : int, RandomState instance or None, optional, default=None + The generator used to randomize the design. If int, random_state is + the seed used by the random number generator; If RandomState instance, + random_state is the random number generator; If None, the random number + generator is the RandomState instance used by `np.random`. n_resampling : int, optional, default=200 Number of randomized models. diff --git a/sklearn/linear_model/ransac.py b/sklearn/linear_model/ransac.py index e4e391cb101c306e2baafd6f797d02d0646393c3..ec23d9a16d4b166a83f0a5b5df6b87c9c527ec90 100644 --- a/sklearn/linear_model/ransac.py +++ b/sklearn/linear_model/ransac.py @@ -158,10 +158,11 @@ class RANSACRegressor(BaseEstimator, MetaEstimatorMixin, RegressorMixin): If the loss on a sample is greater than the ``residual_threshold``, then this sample is classified as an outlier. - random_state : integer or numpy.RandomState, optional - The generator used to initialize the centers. If an integer is - given, it fixes the seed. Defaults to the global numpy random - number generator. + random_state : int, RandomState instance or None, optional, default None + The generator used to initialize the centers. If int, random_state is + the seed used by the random number generator; If RandomState instance, + random_state is the random number generator; If None, the random number + generator is the RandomState instance used by `np.random`. Attributes ---------- diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index 9715e2aaef107884260278251f703819b97b1316..398016b886bdc13ac4a2cf68f229e2ee61fc342f 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -275,9 +275,12 @@ def ridge_regression(X, y, alpha, sample_weight=None, solver='auto', Verbosity level. Setting verbose > 0 will display additional information depending on the solver used. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data. Used only in 'sag' solver. + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Used when ``solver`` == 'sag'. return_n_iter : boolean, default False If True, the method also returns `n_iter`, the actual number of @@ -580,9 +583,12 @@ class Ridge(_BaseRidge, RegressorMixin): tol : float Precision of the solution. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data. Used only in 'sag' solver. + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Used when ``solver`` == 'sag'. .. versionadded:: 0.17 *random_state* to support Stochastic Average Gradient. @@ -728,9 +734,12 @@ class RidgeClassifier(LinearClassifierMixin, _BaseRidge): tol : float Precision of the solution. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data. Used in 'sag' solver. + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Used when ``solver`` == 'sag'. Attributes ---------- diff --git a/sklearn/linear_model/sag.py b/sklearn/linear_model/sag.py index 61bda1b66f4172ee141b26af89ce56f949c8de8a..9bf807a18238cfc73ccbc2a8d2608b9360a02861 100644 --- a/sklearn/linear_model/sag.py +++ b/sklearn/linear_model/sag.py @@ -144,9 +144,12 @@ def sag_solver(X, y, sample_weight=None, loss='log', alpha=1., beta=0., verbose : integer, optional The verbosity level. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data. + random_state : int, RandomState instance or None, optional, default None + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. check_input : bool, default True If False, the input arrays X and y will not be checked. diff --git a/sklearn/linear_model/stochastic_gradient.py b/sklearn/linear_model/stochastic_gradient.py index c234b8eb94f0f17e85d8efce3b60fc542ceb8118..b3c61408470cc35c515415dfa51e97e758b3c153 100644 --- a/sklearn/linear_model/stochastic_gradient.py +++ b/sklearn/linear_model/stochastic_gradient.py @@ -608,9 +608,12 @@ class SGDClassifier(BaseSGDClassifier): Whether or not the training data should be shuffled after each epoch. Defaults to True. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data. + random_state : int, RandomState instance or None, optional (default=None) + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. verbose : integer, optional The verbosity level @@ -1134,9 +1137,12 @@ class SGDRegressor(BaseSGDRegressor): Whether or not the training data should be shuffled after each epoch. Defaults to True. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data. + random_state : int, RandomState instance or None, optional (default=None) + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. verbose : integer, optional The verbosity level. diff --git a/sklearn/linear_model/theil_sen.py b/sklearn/linear_model/theil_sen.py index 23b3c106c9bd7135d2599269fdd6af7d45c478d0..b51f7d6dd3c32cf457068decabb7d0a0af80979b 100644 --- a/sklearn/linear_model/theil_sen.py +++ b/sklearn/linear_model/theil_sen.py @@ -243,9 +243,12 @@ class TheilSenRegressor(LinearModel, RegressorMixin): tol : float, optional, default 1.e-3 Tolerance when calculating spatial median. - random_state : RandomState or an int seed, optional, default None - A random number generator instance to define the state of the - random permutations generator. + random_state : int, RandomState instance or None, optional, default None + A random number generator instance to define the state of the random + permutations generator. If int, random_state is the seed used by the + random number generator; If RandomState instance, random_state is the + random number generator; If None, the random number generator is the + RandomState instance used by `np.random`. n_jobs : integer, optional, default 1 Number of CPUs to use during the cross validation. If ``-1``, use diff --git a/sklearn/manifold/locally_linear.py b/sklearn/manifold/locally_linear.py index 367710edc667eac9e8d01f3ef75aee88a79f5d56..82c4b61254361b157d24a245721bed3c231006c0 100644 --- a/sklearn/manifold/locally_linear.py +++ b/sklearn/manifold/locally_linear.py @@ -140,9 +140,11 @@ def null_space(M, k, k_skip=1, eigen_solver='arpack', tol=1E-6, max_iter=100, max_iter : maximum number of iterations for 'arpack' method not used if eigen_solver=='dense' - random_state : numpy.RandomState or int, optional - The generator or seed used to determine the starting vector for arpack - iterations. Defaults to numpy.random. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Used when ``solver`` == 'arpack'. """ if eigen_solver == 'auto': @@ -245,9 +247,11 @@ def locally_linear_embedding( Tolerance for modified LLE method. Only used if method == 'modified' - random_state : numpy.RandomState or int, optional - The generator or seed used to determine the starting vector for arpack - iterations. Defaults to numpy.random. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Used when ``solver`` == 'arpack'. n_jobs : int, optional (default = 1) The number of parallel jobs to run for neighbors search. @@ -568,9 +572,11 @@ class LocallyLinearEmbedding(BaseEstimator, TransformerMixin): algorithm to use for nearest neighbors search, passed to neighbors.NearestNeighbors instance - random_state : numpy.RandomState or int, optional - The generator or seed used to determine the starting vector for arpack - iterations. Defaults to numpy.random. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Used when ``eigen_solver`` == 'arpack'. n_jobs : int, optional (default = 1) The number of parallel jobs to run. diff --git a/sklearn/manifold/mds.py b/sklearn/manifold/mds.py index b2fe62040bb9362d5a4018ab7079cc5739ee5a9c..5f7327ef4dc84d408f985b713383ec674dc17d78 100644 --- a/sklearn/manifold/mds.py +++ b/sklearn/manifold/mds.py @@ -19,8 +19,7 @@ from ..isotonic import IsotonicRegression def _smacof_single(dissimilarities, metric=True, n_components=2, init=None, max_iter=300, verbose=0, eps=1e-3, random_state=None): - """ - Computes multidimensional scaling using SMACOF algorithm + """Computes multidimensional scaling using SMACOF algorithm Parameters ---------- @@ -50,10 +49,11 @@ def _smacof_single(dissimilarities, metric=True, n_components=2, init=None, Relative tolerance with respect to stress at which to declare convergence. - random_state : integer or numpy.RandomState, optional - The generator used to initialize the centers. If an integer is - given, it fixes the seed. Defaults to the global numpy random - number generator. + random_state : int, RandomState instance or None, optional, default: None + The generator used to initialize the centers. If int, random_state is + the seed used by the random number generator; If RandomState instance, + random_state is the random number generator; If None, the random number + generator is the RandomState instance used by `np.random`. Returns ------- @@ -134,8 +134,7 @@ def _smacof_single(dissimilarities, metric=True, n_components=2, init=None, def smacof(dissimilarities, metric=True, n_components=2, init=None, n_init=8, n_jobs=1, max_iter=300, verbose=0, eps=1e-3, random_state=None, return_n_iter=False): - """ - Computes multidimensional scaling using the SMACOF algorithm. + """Computes multidimensional scaling using the SMACOF algorithm. The SMACOF (Scaling by MAjorizing a COmplicated Function) algorithm is a multidimensional scaling algorithm which minimizes an objective function @@ -198,10 +197,11 @@ def smacof(dissimilarities, metric=True, n_components=2, init=None, n_init=8, Relative tolerance with respect to stress at which to declare convergence. - random_state : integer or numpy.RandomState, optional, default: None - The generator used to initialize the centers. If an integer is given, - it fixes the seed. Defaults to the global numpy random number - generator. + random_state : int, RandomState instance or None, optional, default: None + The generator used to initialize the centers. If int, random_state is + the seed used by the random number generator; If RandomState instance, + random_state is the random number generator; If None, the random number + generator is the RandomState instance used by `np.random`. return_n_iter : bool, optional, default: False Whether or not to return the number of iterations. @@ -314,10 +314,11 @@ class MDS(BaseEstimator): (``n_cpus + 1 + n_jobs``) are used. Thus for ``n_jobs = -2``, all CPUs but one are used. - random_state : integer or numpy.RandomState, optional, default: None - The generator used to initialize the centers. If an integer is given, - it fixes the seed. Defaults to the global numpy random number - generator. + random_state : int, RandomState instance or None, optional, default: None + The generator used to initialize the centers. If int, random_state is + the seed used by the random number generator; If RandomState instance, + random_state is the random number generator; If None, the random number + generator is the RandomState instance used by `np.random`. dissimilarity : 'euclidean' | 'precomputed', optional, default: 'euclidean' Dissimilarity measure to use: diff --git a/sklearn/manifold/spectral_embedding_.py b/sklearn/manifold/spectral_embedding_.py index 6250565645cd2dc813d9b8b7cab918f3b2ca4d81..31c90aa8b30aa6c6d4f298013eb1f5f4b9de7100 100644 --- a/sklearn/manifold/spectral_embedding_.py +++ b/sklearn/manifold/spectral_embedding_.py @@ -166,10 +166,13 @@ def spectral_embedding(adjacency, n_components=8, eigen_solver=None, to be installed. It can be faster on very large, sparse problems, but may also lead to instabilities. - random_state : int seed, RandomState instance, or None (default) + random_state : int, RandomState instance or None, optional, default: None A pseudo random number generator used for the initialization of the - lobpcg eigenvectors decomposition when eigen_solver == 'amg'. - By default, arpack is used. + lobpcg eigenvectors decomposition. If int, random_state is the seed + used by the random number generator; If RandomState instance, + random_state is the random number generator; If None, the random number + generator is the RandomState instance used by `np.random`. Used when + ``solver`` == 'amg'. eigen_tol : float, optional, default=0.0 Stopping criterion for eigendecomposition of the Laplacian matrix @@ -345,9 +348,13 @@ class SpectralEmbedding(BaseEstimator): to be installed. It can be faster on very large, sparse problems, but may also lead to instabilities. - random_state : int seed, RandomState instance, or None, default : None + random_state : int, RandomState instance or None, optional, default: None A pseudo random number generator used for the initialization of the - lobpcg eigenvectors decomposition when eigen_solver == 'amg'. + lobpcg eigenvectors. If int, random_state is the seed used by the + random number generator; If RandomState instance, random_state is the + random number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Used when ``solver`` == + 'amg'. affinity : string or callable, default : "nearest_neighbors" How to construct the affinity matrix. diff --git a/sklearn/manifold/t_sne.py b/sklearn/manifold/t_sne.py index a124753cb04988d1a83221f15df772a2a2c048c0..83d42c444fa5c7f4d084a4de1fc4f97cf5b8e459 100644 --- a/sklearn/manifold/t_sne.py +++ b/sklearn/manifold/t_sne.py @@ -582,10 +582,12 @@ class TSNE(BaseEstimator): verbose : int, optional (default: 0) Verbosity level. - random_state : int or RandomState instance or None (default) - Pseudo Random Number generator seed control. If None, use the - numpy.random singleton. Note that different initializations - might result in different local minima of the cost function. + random_state : int, RandomState instance or None, optional (default: None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Note that different initializations might result in + different local minima of the cost function. method : string (default: 'barnes_hut') By default the gradient calculation algorithm uses Barnes-Hut diff --git a/sklearn/metrics/cluster/unsupervised.py b/sklearn/metrics/cluster/unsupervised.py index 606ffcddf849452f241dd09612aebe8ebeaddf0d..3be683ae08d9810b6a1ac2251087a4b76dc52a58 100644 --- a/sklearn/metrics/cluster/unsupervised.py +++ b/sklearn/metrics/cluster/unsupervised.py @@ -62,10 +62,12 @@ def silhouette_score(X, labels, metric='euclidean', sample_size=None, on a random subset of the data. If ``sample_size is None``, no sampling is used. - random_state : integer or numpy.RandomState, optional - The generator used to randomly select a subset of samples if - ``sample_size is not None``. If an integer is given, it fixes the seed. - Defaults to the global numpy random number generator. + random_state : int, RandomState instance or None, optional (default=None) + The generator used to randomly select a subset of samples. If int, + random_state is the seed used by the random number generator; If + RandomState instance, random_state is the random number generator; If + None, the random number generator is the RandomState instance used by + `np.random`. Used when ``sample_size is not None``. **kwds : optional keyword parameters Any further parameters are passed directly to the distance function. diff --git a/sklearn/mixture/bayesian_mixture.py b/sklearn/mixture/bayesian_mixture.py index 497b339a4f80784bf86361d5c4396c5321f8cf78..24c0ae62e4efbfb040da8d52dcafe3b2fbfa546a 100644 --- a/sklearn/mixture/bayesian_mixture.py +++ b/sklearn/mixture/bayesian_mixture.py @@ -163,8 +163,11 @@ class BayesianGaussianMixture(BaseMixture): (n_features) if 'diag', float if 'spherical' - random_state : RandomState or an int seed, defaults to None. - A random number generator instance. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. warm_start : bool, default to False. If 'warm_start' is True, the solution of the last fitting is used as diff --git a/sklearn/mixture/gaussian_mixture.py b/sklearn/mixture/gaussian_mixture.py index edbfc08c4e07d67142d4f79c8849252287dc9325..eced5407249402603308f53ffe2634e02c79d524 100644 --- a/sklearn/mixture/gaussian_mixture.py +++ b/sklearn/mixture/gaussian_mixture.py @@ -500,8 +500,11 @@ class GaussianMixture(BaseMixture): (n_components, n_features) if 'diag', (n_components, n_features, n_features) if 'full' - random_state : RandomState or an int seed, defaults to None. - A random number generator instance. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. warm_start : bool, default to False. If 'warm_start' is True, the solution of the last fitting is used as diff --git a/sklearn/mixture/gmm.py b/sklearn/mixture/gmm.py index 024981bda8fade2624d87272751d4bc38f4f202f..5b2dece572c34aa13c618f102d366d72d001bf09 100644 --- a/sklearn/mixture/gmm.py +++ b/sklearn/mixture/gmm.py @@ -152,8 +152,11 @@ class _GMMBase(BaseEstimator): use. Must be one of 'spherical', 'tied', 'diag', 'full'. Defaults to 'diag'. - random_state : RandomState or an int seed (None by default) - A random number generator instance + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. min_covar : float, optional Floor on the diagonal of the covariance matrix to prevent diff --git a/sklearn/model_selection/_search.py b/sklearn/model_selection/_search.py index 3b8a0ed882cf56a46057136d325b193c64713b5a..98d9e32017e46309fdcb021c96e2f8e7846309d6 100644 --- a/sklearn/model_selection/_search.py +++ b/sklearn/model_selection/_search.py @@ -192,9 +192,13 @@ class ParameterSampler(object): n_iter : integer Number of parameter settings that are produced. - random_state : int or RandomState + random_state : int, RandomState instance or None, optional (default=None) Pseudo random number generator state used for random uniform sampling from lists of possible values instead of scipy.stats distributions. + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Returns ------- @@ -1054,9 +1058,13 @@ class RandomizedSearchCV(BaseSearchCV): verbose : integer Controls the verbosity: the higher, the more messages. - random_state : int or RandomState + random_state : int, RandomState instance or None, optional, default=None Pseudo random number generator state used for random uniform sampling from lists of possible values instead of scipy.stats distributions. + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. error_score : 'raise' (default) or numeric Value to assign to the score if an error occurs in estimator fitting. diff --git a/sklearn/model_selection/_split.py b/sklearn/model_selection/_split.py index 992c4f6d81e6a4ef4566339770d70f8e4f8e622d..0eb51be93f5bb266b4780ea14e0b5f41b8a2420d 100644 --- a/sklearn/model_selection/_split.py +++ b/sklearn/model_selection/_split.py @@ -364,9 +364,11 @@ class KFold(_BaseKFold): shuffle : boolean, optional Whether to shuffle the data before splitting into batches. - random_state : None, int or RandomState - When shuffle=True, pseudo-random number generator state used for - shuffling. If None, use default numpy RNG for shuffling. + random_state : int, RandomState instance or None, optional, default=None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Used when ``shuffle`` == True. Examples -------- @@ -531,9 +533,11 @@ class StratifiedKFold(_BaseKFold): Whether to shuffle each stratification of the data before splitting into batches. - random_state : None, int or RandomState - When shuffle=True, pseudo-random number generator state used for - shuffling. If None, use default numpy RNG for shuffling. + random_state : int, RandomState instance or None, optional, default=None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Used when ``shuffle`` == True. Examples -------- @@ -934,9 +938,11 @@ class _RepeatedSplits(with_metaclass(ABCMeta)): n_repeats : int, default=10 Number of times cross-validator needs to be repeated. - random_state : None, int or RandomState, default=None - Random state to be used to generate random state for each - repetition. + random_state : int, RandomState instance or None, optional, default=None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. **cvargs : additional params Constructor parameters for cv. Must not contain random_state @@ -1007,9 +1013,11 @@ class RepeatedKFold(_RepeatedSplits): n_repeats : int, default=10 Number of times cross-validator needs to be repeated. - random_state : None, int or RandomState, default=None - Random state to be used to generate random state for each - repetition. + random_state : int, RandomState instance or None, optional, default=None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Examples -------- @@ -1180,8 +1188,11 @@ class ShuffleSplit(BaseShuffleSplit): int, represents the absolute number of train samples. If None, the value is automatically set to the complement of the test size. - random_state : int or RandomState - Pseudo-random number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Examples -------- @@ -1262,8 +1273,12 @@ class GroupShuffleSplit(ShuffleSplit): int, represents the absolute number of train groups. If None, the value is automatically set to the complement of the test size. - random_state : int or RandomState - Pseudo-random number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. + ''' def __init__(self, n_splits=5, test_size=0.2, train_size=None, @@ -1389,8 +1404,12 @@ class StratifiedShuffleSplit(BaseShuffleSplit): int, represents the absolute number of train samples. If None, the value is automatically set to the complement of the test size. - random_state : int or RandomState - Pseudo-random number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. + Examples -------- @@ -1795,8 +1814,11 @@ def train_test_split(*arrays, **options): int, represents the absolute number of train samples. If None, the value is automatically set to the complement of the test size. - random_state : int or RandomState - Pseudo-random number generator state used for random sampling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. stratify : array-like or None (default is None) If not None, data is split in a stratified fashion, using this as diff --git a/sklearn/model_selection/_validation.py b/sklearn/model_selection/_validation.py index e65720b709555982e887f4992fdd9f7cb87b6117..e105f0d0b122f00f77597d9f5cf78c8ccdde9063 100644 --- a/sklearn/model_selection/_validation.py +++ b/sklearn/model_selection/_validation.py @@ -580,9 +580,11 @@ def permutation_test_score(estimator, X, y, groups=None, cv=None, The number of CPUs to use to do the computation. -1 means 'all CPUs'. - random_state : RandomState or an int seed (0 by default) - A random number generator instance to define the state of the - random permutations generator. + random_state : int, RandomState instance or None, optional (default=0) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. verbose : integer, optional The verbosity level. @@ -743,9 +745,11 @@ def learning_curve(estimator, X, y, groups=None, Whether to shuffle training data before taking prefixes of it based on``train_sizes``. - random_state : None, int or RandomState - When shuffle=True, pseudo-random number generator state used for - shuffling. If None, use default numpy RNG for shuffling. + random_state : int, RandomState instance or None, optional (default=None) + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. Used when ``shuffle`` == 'True'. ------- train_sizes_abs : array, shape = (n_unique_ticks,), dtype int diff --git a/sklearn/multiclass.py b/sklearn/multiclass.py index 3de5ee319c71820bc8107569527d095759e0c2df..8f9788e6a425ce504cb71ca92700cb187499eacd 100644 --- a/sklearn/multiclass.py +++ b/sklearn/multiclass.py @@ -640,9 +640,11 @@ class OutputCodeClassifier(BaseEstimator, ClassifierMixin, MetaEstimatorMixin): one-vs-the-rest. A number greater than 1 will require more classifiers than one-vs-the-rest. - random_state : numpy.RandomState, optional - The generator used to initialize the codebook. Defaults to - numpy.random. + random_state : int, RandomState instance or None, optional, default: None + The generator used to initialize the codebook. If int, random_state is + the seed used by the random number generator; If RandomState instance, + random_state is the random number generator; If None, the random number + generator is the RandomState instance used by `np.random`. n_jobs : int, optional, default: 1 The number of jobs to use for the computation. If -1 all CPUs are used. diff --git a/sklearn/neighbors/kde.py b/sklearn/neighbors/kde.py index dfb349a8dc424f227810d191df186d502698f36f..3cfdbc63042b77aad2fe06e330bd972f4637a196 100644 --- a/sklearn/neighbors/kde.py +++ b/sklearn/neighbors/kde.py @@ -184,8 +184,11 @@ class KernelDensity(BaseEstimator): n_samples : int, optional Number of samples to generate. Defaults to 1. - random_state : RandomState or an int seed (0 by default) - A random number generator instance. + random_state : int, RandomState instance or None. default to None + If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random + number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Returns ------- diff --git a/sklearn/neural_network/multilayer_perceptron.py b/sklearn/neural_network/multilayer_perceptron.py index 720a3fef21d84086c4f276353ec7c973aad226ff..1d329f8074c20dc12118cd39789d1b564ebeb155 100644 --- a/sklearn/neural_network/multilayer_perceptron.py +++ b/sklearn/neural_network/multilayer_perceptron.py @@ -755,8 +755,11 @@ class MLPClassifier(BaseMultilayerPerceptron, ClassifierMixin): Maximum number of iterations. The solver iterates until convergence (determined by 'tol') or this number of iterations. - random_state : int or RandomState, optional, default None - State or seed for random number generator. + random_state : int, RandomState instance or None, optional, default None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. shuffle : bool, optional, default True Whether to shuffle samples in each iteration. Only used when @@ -1126,8 +1129,11 @@ class MLPRegressor(BaseMultilayerPerceptron, RegressorMixin): Maximum number of iterations. The solver iterates until convergence (determined by 'tol') or this number of iterations. - random_state : int or RandomState, optional, default None - State or seed for random number generator. + random_state : int, RandomState instance or None, optional, default None + If int, random_state is the seed used by the random number generator; + If RandomState instance, random_state is the random number generator; + If None, the random number generator is the RandomState instance used + by `np.random`. shuffle : bool, optional, default True Whether to shuffle samples in each iteration. Only used when diff --git a/sklearn/random_projection.py b/sklearn/random_projection.py index 0d47b2886ff0ec5090a45af1dfbc390f471280d5..1ec4d0d21e678657a4d1c2c94d1c8756c2474fa3 100644 --- a/sklearn/random_projection.py +++ b/sklearn/random_projection.py @@ -154,7 +154,7 @@ def _check_input_size(n_components, n_features): def gaussian_random_matrix(n_components, n_features, random_state=None): - """ Generate a dense Gaussian random matrix. + """Generate a dense Gaussian random matrix. The components of the random matrix are drawn from @@ -170,9 +170,12 @@ def gaussian_random_matrix(n_components, n_features, random_state=None): n_features : int, Dimensionality of the original source space. - random_state : int, RandomState instance or None (default=None) - Control the pseudo random number generator used to generate the - matrix at fit time. + random_state : int, RandomState instance or None, optional (default=None) + Control the pseudo random number generator used to generate the matrix + at fit time. If int, random_state is the seed used by the random + number generator; If RandomState instance, random_state is the random + number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Returns ------- @@ -226,9 +229,12 @@ def sparse_random_matrix(n_components, n_features, density='auto', Use density = 1 / 3.0 if you want to reproduce the results from Achlioptas, 2001. - random_state : integer, RandomState instance or None (default=None) - Control the pseudo random number generator used to generate the - matrix at fit time. + random_state : int, RandomState instance or None, optional (default=None) + Control the pseudo random number generator used to generate the matrix + at fit time. If int, random_state is the seed used by the random + number generator; If RandomState instance, random_state is the random + number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Returns ------- @@ -446,9 +452,12 @@ class GaussianRandomProjection(BaseRandomProjection): Smaller values lead to better embedding and higher number of dimensions (n_components) in the target projection space. - random_state : integer, RandomState instance or None (default=None) - Control the pseudo random number generator used to generate the - matrix at fit time. + random_state : int, RandomState instance or None, optional (default=None) + Control the pseudo random number generator used to generate the matrix + at fit time. If int, random_state is the seed used by the random + number generator; If RandomState instance, random_state is the random + number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Attributes ---------- @@ -552,9 +561,12 @@ class SparseRandomProjection(BaseRandomProjection): If False, the projected data uses a sparse representation if the input is sparse. - random_state : integer, RandomState instance or None (default=None) - Control the pseudo random number generator used to generate the - matrix at fit time. + random_state : int, RandomState instance or None, optional (default=None) + Control the pseudo random number generator used to generate the matrix + at fit time. If int, random_state is the seed used by the random + number generator; If RandomState instance, random_state is the random + number generator; If None, the random number generator is the + RandomState instance used by `np.random`. Attributes ---------- diff --git a/sklearn/svm/base.py b/sklearn/svm/base.py index cff4c35a58b46a588776920a343ca930b44738f6..208a69f3720c8b7ced2db8ffcafa3ba534858f18 100644 --- a/sklearn/svm/base.py +++ b/sklearn/svm/base.py @@ -804,9 +804,13 @@ def _fit_liblinear(X, y, C, fit_intercept, intercept_scaling, class_weight, tol : float Stopping condition. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data. + random_state : int, RandomState instance or None, optional (default=None) + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. + multi_class : str, {'ovr', 'crammer_singer'} `ovr` trains n_classes one-vs-rest classifiers, while `crammer_singer` diff --git a/sklearn/svm/classes.py b/sklearn/svm/classes.py index 7e920011d002db701da77efba35392ec932e2d54..2de3029cb2f26d1298d2f6bd76739ded543df10c 100644 --- a/sklearn/svm/classes.py +++ b/sklearn/svm/classes.py @@ -86,9 +86,12 @@ class LinearSVC(BaseEstimator, LinearClassifierMixin, per-process runtime setting in liblinear that, if enabled, may not work properly in a multithreaded context. - random_state : int seed, RandomState instance, or None (default=None) - The seed of the pseudo random number generator to use when - shuffling the data. + random_state : int, RandomState instance or None, optional (default=None) + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. max_iter : int, (default=1000) The maximum number of iterations to be run. @@ -277,9 +280,12 @@ class LinearSVR(LinearModel, RegressorMixin): per-process runtime setting in liblinear that, if enabled, may not work properly in a multithreaded context. - random_state : int seed, RandomState instance, or None (default=None) - The seed of the pseudo random number generator to use when - shuffling the data. + random_state : int, RandomState instance or None, optional (default=None) + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. max_iter : int, (default=1000) The maximum number of iterations to be run. @@ -468,9 +474,12 @@ class SVC(BaseSVC): .. versionchanged:: 0.17 Deprecated *decision_function_shape='ovo' and None*. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data for probability estimation. + random_state : int, RandomState instance or None, optional (default=None) + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Attributes ---------- @@ -621,9 +630,12 @@ class NuSVC(BaseSVC): .. versionchanged:: 0.17 Deprecated *decision_function_shape='ovo' and None*. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data for probability estimation. + random_state : int, RandomState instance or None, optional (default=None) + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Attributes ---------- @@ -972,9 +984,12 @@ class OneClassSVM(BaseLibSVM): max_iter : int, optional (default=-1) Hard limit on iterations within solver, or -1 for no limit. - random_state : int seed, RandomState instance, or None (default) - The seed of the pseudo random number generator to use when - shuffling the data for probability estimation. + random_state : int, RandomState instance or None, optional (default=None) + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Attributes ---------- diff --git a/sklearn/utils/__init__.py b/sklearn/utils/__init__.py index 0bc4d6de33c3f17d33e693ce970a36a0f961b237..b3e41e1c130fbc15af7d3a5009586f56866d666b 100644 --- a/sklearn/utils/__init__.py +++ b/sklearn/utils/__init__.py @@ -175,8 +175,12 @@ def resample(*arrays, **options): If replace is False it should not be larger than the length of arrays. - random_state : int or RandomState instance - Control the shuffling for reproducible behavior. + random_state : int, RandomState instance or None, optional (default=None) + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Returns ------- @@ -271,8 +275,12 @@ def shuffle(*arrays, **options): Indexable data-structures can be arrays, lists, dataframes or scipy sparse matrices with consistent first dimension. - random_state : int or RandomState instance - Control the shuffling for reproducible behavior. + random_state : int, RandomState instance or None, optional (default=None) + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. n_samples : int, None by default Number of samples to generate. If left to None this is diff --git a/sklearn/utils/extmath.py b/sklearn/utils/extmath.py index df1f56dbcb8913e8dc9e14c404bbdf87aa6bdad7..d797950ba8efa5c1e511d942a8afb844c20a7c97 100644 --- a/sklearn/utils/extmath.py +++ b/sklearn/utils/extmath.py @@ -215,8 +215,12 @@ def randomized_range_finder(A, size, n_iter, .. versionadded:: 0.18 - random_state : RandomState or an int seed (0 by default) - A random number generator instance + random_state : int, RandomState instance or None, optional (default=None) + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Returns ------- @@ -320,8 +324,12 @@ def randomized_svd(M, n_components, n_oversamples=10, n_iter='auto', set to `True`, the sign ambiguity is resolved by making the largest loadings for each component in the left singular vectors positive. - random_state : RandomState or an int seed (0 by default) - A random number generator instance to make behavior + random_state : int, RandomState instance or None, optional (default=None) + The seed of the pseudo random number generator to use when shuffling + the data. If int, random_state is the seed used by the random number + generator; If RandomState instance, random_state is the random number + generator; If None, the random number generator is the RandomState + instance used by `np.random`. Notes -----