Skip to content

Commit 38030a0

Browse files
committed
[MRG + 1] More versionadded everywhere! (scikit-learn#7403)
* insert versionadded versionchanged directives in docstrings for 0.18 indicate where exception classes were moved from * moved versionadded in the proper places
1 parent 191a93d commit 38030a0

File tree

15 files changed

+184
-8
lines changed

15 files changed

+184
-8
lines changed

sklearn/datasets/kddcup99.py

+3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ def fetch_kddcup99(subset=None, shuffle=False, random_state=None,
116116
Targets str, 'normal.' or name of the anomaly type
117117
================ ==========================================
118118
119+
.. versionadded:: 0.18
120+
119121
Parameters
120122
----------
121123
subset : None, 'SA', 'SF', 'http', 'smtp'
@@ -156,6 +158,7 @@ def fetch_kddcup99(subset=None, shuffle=False, random_state=None,
156158
.. [2] A Geometric Framework for Unsupervised Anomaly Detection: Detecting
157159
Intrusions in Unlabeled Data (2002) by Eleazar Eskin, Andrew Arnold,
158160
Michael Prerau, Leonid Portnoy, Sal Stolfo
161+
159162
"""
160163
kddcup99 = _fetch_brute_kddcup99(shuffle=shuffle, percent10=percent10,
161164
download_if_missing=download_if_missing)

sklearn/decomposition/kernel_pca.py

+6
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,21 @@ class KernelPCA(BaseEstimator, TransformerMixin):
7878
A pseudo random number generator used for the initialization of the
7979
residuals when eigen_solver == 'arpack'.
8080
81+
.. versionadded:: 0.18
82+
8183
n_jobs : int, default=1
8284
The number of parallel jobs to run.
8385
If `-1`, then the number of jobs is set to the number of CPU cores.
8486
87+
.. versionadded:: 0.18
88+
8589
copy_X : boolean, default=True
8690
If True, input X is copied and stored by the model in the `X_fit_`
8791
attribute. If no further changes will be done to X, setting
8892
`copy_X=False` saves memory by storing a reference.
8993
94+
.. versionadded:: 0.18
95+
9096
Attributes
9197
----------
9298
lambdas_ : array, (n_components,)

sklearn/decomposition/pca.py

+2
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ class PCA(_BasePCA):
194194
explained_variance_ : array, [n_components]
195195
The amount of variance explained by each of the selected components.
196196
197+
.. versionadded:: 0.18
198+
197199
explained_variance_ratio_ : array, [n_components]
198200
Percentage of variance explained by each of the selected components.
199201

sklearn/ensemble/forest.py

+36
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,15 @@ class calls the ``fit`` method of each sub-estimator on random samples
7373

7474
MAX_INT = np.iinfo(np.int32).max
7575

76+
7677
def _generate_sample_indices(random_state, n_samples):
7778
"""Private function used to _parallel_build_trees function."""
7879
random_instance = check_random_state(random_state)
7980
sample_indices = random_instance.randint(0, n_samples, n_samples)
8081

8182
return sample_indices
8283

84+
8385
def _generate_unsampled_indices(random_state, n_samples):
8486
"""Private function used to forest._set_oob_score function."""
8587
sample_indices = _generate_sample_indices(random_state, n_samples)
@@ -90,6 +92,7 @@ def _generate_unsampled_indices(random_state, n_samples):
9092

9193
return unsampled_indices
9294

95+
9396
def _parallel_build_trees(tree, forest, X, y, sample_weight, tree_idx, n_trees,
9497
verbose=0, class_weight=None):
9598
"""Private function used to fit a single tree in parallel."""
@@ -181,6 +184,8 @@ def apply(self, X):
181184
def decision_path(self, X):
182185
"""Return the decision path in the forest
183186
187+
.. versionadded:: 0.18
188+
184189
Parameters
185190
----------
186191
X : array-like or sparse matrix, shape = [n_samples, n_features]
@@ -197,6 +202,7 @@ def decision_path(self, X):
197202
n_nodes_ptr : array of size (n_estimators + 1, )
198203
The columns from indicator[n_nodes_ptr[i]:n_nodes_ptr[i+1]]
199204
gives the indicator value for the i-th estimator.
205+
200206
"""
201207
X = self._validate_X_predict(X)
202208
indicators = Parallel(n_jobs=self.n_jobs, verbose=self.verbose,
@@ -786,6 +792,9 @@ class RandomForestClassifier(ForestClassifier):
786792
`ceil(min_samples_split * n_samples)` are the minimum
787793
number of samples for each split.
788794
795+
.. versionchanged:: 0.18
796+
Added float values for percentages.
797+
789798
min_samples_leaf : int, float, optional (default=1)
790799
The minimum number of samples required to be at a leaf node:
791800
@@ -794,6 +803,9 @@ class RandomForestClassifier(ForestClassifier):
794803
`ceil(min_samples_leaf * n_samples)` are the minimum
795804
number of samples for each node.
796805
806+
.. versionchanged:: 0.18
807+
Added float values for percentages.
808+
797809
min_weight_fraction_leaf : float, optional (default=0.)
798810
The minimum weighted fraction of the input samples required to be at a
799811
leaf node.
@@ -991,6 +1003,9 @@ class RandomForestRegressor(ForestRegressor):
9911003
`ceil(min_samples_split * n_samples)` are the minimum
9921004
number of samples for each split.
9931005
1006+
.. versionchanged:: 0.18
1007+
Added float values for percentages.
1008+
9941009
min_samples_leaf : int, float, optional (default=1)
9951010
The minimum number of samples required to be at a leaf node:
9961011
@@ -999,6 +1014,9 @@ class RandomForestRegressor(ForestRegressor):
9991014
`ceil(min_samples_leaf * n_samples)` are the minimum
10001015
number of samples for each node.
10011016
1017+
.. versionchanged:: 0.18
1018+
Added float values for percentages.
1019+
10021020
min_weight_fraction_leaf : float, optional (default=0.)
10031021
The minimum weighted fraction of the input samples required to be at a
10041022
leaf node.
@@ -1156,6 +1174,9 @@ class ExtraTreesClassifier(ForestClassifier):
11561174
`ceil(min_samples_split * n_samples)` are the minimum
11571175
number of samples for each split.
11581176
1177+
.. versionchanged:: 0.18
1178+
Added float values for percentages.
1179+
11591180
min_samples_leaf : int, float, optional (default=1)
11601181
The minimum number of samples required to be at a leaf node:
11611182
@@ -1164,6 +1185,9 @@ class ExtraTreesClassifier(ForestClassifier):
11641185
`ceil(min_samples_leaf * n_samples)` are the minimum
11651186
number of samples for each node.
11661187
1188+
.. versionchanged:: 0.18
1189+
Added float values for percentages.
1190+
11671191
min_weight_fraction_leaf : float, optional (default=0.)
11681192
The minimum weighted fraction of the input samples required to be at a
11691193
leaf node.
@@ -1360,6 +1384,9 @@ class ExtraTreesRegressor(ForestRegressor):
13601384
`ceil(min_samples_split * n_samples)` are the minimum
13611385
number of samples for each split.
13621386
1387+
.. versionchanged:: 0.18
1388+
Added float values for percentages.
1389+
13631390
min_samples_leaf : int, float, optional (default=1)
13641391
The minimum number of samples required to be at a leaf node:
13651392
@@ -1368,6 +1395,9 @@ class ExtraTreesRegressor(ForestRegressor):
13681395
`ceil(min_samples_leaf * n_samples)` are the minimum
13691396
number of samples for each node.
13701397
1398+
.. versionchanged:: 0.18
1399+
Added float values for percentages.
1400+
13711401
min_weight_fraction_leaf : float, optional (default=0.)
13721402
The minimum weighted fraction of the input samples required to be at a
13731403
leaf node.
@@ -1511,6 +1541,9 @@ class RandomTreesEmbedding(BaseForest):
15111541
`ceil(min_samples_split * n_samples)` is the minimum
15121542
number of samples for each split.
15131543
1544+
.. versionchanged:: 0.18
1545+
Added float values for percentages.
1546+
15141547
min_samples_leaf : int, float, optional (default=1)
15151548
The minimum number of samples required to be at a leaf node:
15161549
@@ -1519,6 +1552,9 @@ class RandomTreesEmbedding(BaseForest):
15191552
`ceil(min_samples_leaf * n_samples)` is the minimum
15201553
number of samples for each node.
15211554
1555+
.. versionchanged:: 0.18
1556+
Added float values for percentages.
1557+
15221558
min_weight_fraction_leaf : float, optional (default=0.)
15231559
The minimum weighted fraction of the input samples required to be at a
15241560
leaf node.

sklearn/ensemble/gradient_boosting.py

+11
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,9 @@ class GradientBoostingClassifier(BaseGradientBoosting, ClassifierMixin):
13151315
`ceil(min_samples_split * n_samples)` are the minimum
13161316
number of samples for each split.
13171317
1318+
.. versionchanged:: 0.18
1319+
Added float values for percentages.
1320+
13181321
min_samples_leaf : int, float, optional (default=1)
13191322
The minimum number of samples required to be at a leaf node:
13201323
@@ -1323,6 +1326,8 @@ class GradientBoostingClassifier(BaseGradientBoosting, ClassifierMixin):
13231326
`ceil(min_samples_leaf * n_samples)` are the minimum
13241327
number of samples for each node.
13251328
1329+
.. versionchanged:: 0.18
1330+
Added float values for percentages.
13261331
13271332
min_weight_fraction_leaf : float, optional (default=0.)
13281333
The minimum weighted fraction of the input samples required to be at a
@@ -1678,6 +1683,9 @@ class GradientBoostingRegressor(BaseGradientBoosting, RegressorMixin):
16781683
`ceil(min_samples_split * n_samples)` are the minimum
16791684
number of samples for each split.
16801685
1686+
.. versionchanged:: 0.18
1687+
Added float values for percentages.
1688+
16811689
min_samples_leaf : int, float, optional (default=1)
16821690
The minimum number of samples required to be at a leaf node:
16831691
@@ -1686,6 +1694,9 @@ class GradientBoostingRegressor(BaseGradientBoosting, RegressorMixin):
16861694
`ceil(min_samples_leaf * n_samples)` are the minimum
16871695
number of samples for each node.
16881696
1697+
.. versionchanged:: 0.18
1698+
Added float values for percentages.
1699+
16891700
min_weight_fraction_leaf : float, optional (default=0.)
16901701
The minimum weighted fraction of the input samples required to be at a
16911702
leaf node.

sklearn/ensemble/iforest.py

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class IsolationForest(BaseBagging):
4444
4545
Read more in the :ref:`User Guide <isolation_forest>`.
4646
47+
.. versionadded:: 0.18
48+
4749
Parameters
4850
----------
4951
n_estimators : int, optional (default=100)
@@ -106,6 +108,7 @@ class IsolationForest(BaseBagging):
106108
.. [2] Liu, Fei Tony, Ting, Kai Ming and Zhou, Zhi-Hua. "Isolation-based
107109
anomaly detection." ACM Transactions on Knowledge Discovery from
108110
Data (TKDD) 6.1 (2012): 3.
111+
109112
"""
110113

111114
def __init__(self,

sklearn/exceptions.py

+32-3
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,26 @@ class NotFittedError(ValueError, AttributeError):
3030
... print(repr(e))
3131
... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
3232
NotFittedError('This LinearSVC instance is not fitted yet',)
33+
34+
.. versionchanged:: 0.18
35+
Moved from sklearn.utils.validation.
3336
"""
3437

3538

3639
class ChangedBehaviorWarning(UserWarning):
37-
"""Warning class used to notify the user of any change in the behavior."""
40+
"""Warning class used to notify the user of any change in the behavior.
41+
42+
.. versionchanged:: 0.18
43+
Moved from sklearn.base.
44+
"""
3845

3946

4047
class ConvergenceWarning(UserWarning):
41-
"""Custom warning to capture convergence problems"""
48+
"""Custom warning to capture convergence problems
49+
50+
.. versionchanged:: 0.18
51+
Moved from sklearn.utils.
52+
"""
4253

4354

4455
class DataConversionWarning(UserWarning):
@@ -53,6 +64,9 @@ class DataConversionWarning(UserWarning):
5364
- requests a non-copying operation, but a copy is required to meet the
5465
implementation's data-type expectations;
5566
- passes an input whose shape can be interpreted ambiguously.
67+
68+
.. versionchanged:: 0.18
69+
Moved from sklearn.utils.validation.
5670
"""
5771

5872

@@ -64,6 +78,9 @@ class DataDimensionalityWarning(UserWarning):
6478
projection space, is higher than the number of features, which quantifies
6579
the dimensionality of the original source space, to imply that the
6680
dimensionality of the problem will not be reduced.
81+
82+
.. versionchanged:: 0.18
83+
Moved from sklearn.utils.
6784
"""
6885

6986

@@ -73,6 +90,8 @@ class EfficiencyWarning(UserWarning):
7390
This warning notifies the user that the efficiency may not be optimal due
7491
to some reason which may be included as a part of the warning message.
7592
This may be subclassed into a more specific Warning class.
93+
94+
.. versionadded:: 0.18
7695
"""
7796

7897

@@ -102,6 +121,9 @@ class FitFailedWarning(RuntimeWarning):
102121
FitFailedWarning("Classifier fit failed. The score on this train-test
103122
partition for these parameters will be set to 0.000000. Details:
104123
\\nValueError('Penalty term must be positive; got (C=-2)',)",)
124+
125+
.. versionchanged:: 0.18
126+
Moved from sklearn.cross_validation.
105127
"""
106128

107129

@@ -110,8 +132,15 @@ class NonBLASDotWarning(EfficiencyWarning):
110132
111133
This warning is used to notify the user that BLAS was not used for dot
112134
operation and hence the efficiency may be affected.
135+
136+
.. versionchanged:: 0.18
137+
Moved from sklearn.utils.validation, extends EfficiencyWarning.
113138
"""
114139

115140

116141
class UndefinedMetricWarning(UserWarning):
117-
"""Warning used when the metric is invalid"""
142+
"""Warning used when the metric is invalid
143+
144+
.. versionchanged:: 0.18
145+
Moved from sklearn.base.
146+
"""

sklearn/gaussian_process/gpc.py

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class _BinaryGaussianProcessClassifierLaplace(BaseEstimator):
4545
Currently, the implementation is restricted to using the logistic link
4646
function.
4747
48+
.. versionadded:: 0.18
49+
4850
Parameters
4951
----------
5052
kernel : kernel object
@@ -138,6 +140,7 @@ def optimizer(obj_func, initial_theta, bounds):
138140
139141
log_marginal_likelihood_value_: float
140142
The log-marginal-likelihood of ``self.kernel_.theta``
143+
141144
"""
142145
def __init__(self, kernel=None, optimizer="fmin_l_bfgs_b",
143146
n_restarts_optimizer=0, max_iter_predict=100,
@@ -546,6 +549,8 @@ def optimizer(obj_func, initial_theta, bounds):
546549
547550
n_classes_ : int
548551
The number of classes in the training data
552+
553+
.. versionadded:: 0.18
549554
"""
550555
def __init__(self, kernel=None, optimizer="fmin_l_bfgs_b",
551556
n_restarts_optimizer=0, max_iter_predict=100,

sklearn/gaussian_process/gpr.py

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class GaussianProcessRegressor(BaseEstimator, RegressorMixin):
3535
3636
Read more in the :ref:`User Guide <gaussian_process>`.
3737
38+
.. versionadded:: 0.18
39+
3840
Parameters
3941
----------
4042
kernel : kernel object
@@ -125,6 +127,7 @@ def optimizer(obj_func, initial_theta, bounds):
125127
126128
log_marginal_likelihood_value_: float
127129
The log-marginal-likelihood of ``self.kernel_.theta``
130+
128131
"""
129132
def __init__(self, kernel=None, alpha=1e-10,
130133
optimizer="fmin_l_bfgs_b", n_restarts_optimizer=0,

0 commit comments

Comments
 (0)