Skip to content

Commit b87304d

Browse files
thomasjpfanjeremiedbbtsugaConnerrrrrglemaitre
authored
DOC Fix GitHub regex labeler (#75)
* TST enable test docstring params for feature extraction module (scikit-learn#20188) * DOC fix a reference in sklearn.ensemble.GradientBoostingRegressor (scikit-learn#20198) * FIX mcc zero divsion (scikit-learn#19977) * TST Add TransformedTargetRegressor to test_meta_estimators_delegate_data_validation (scikit-learn#20175) Co-authored-by: Guillaume Lemaitre <[email protected]> * TST enable n_feature_in_ test for feature_extraction module * FIX Uses points instead of pixels in plot_tree (scikit-learn#20023) * MNT n_features_in through the multiclass module (scikit-learn#20193) * CI Removes python 3.6 builds from wheel building (scikit-learn#20184) * FIX Fix typo in error message in `fetch_openml` (scikit-learn#20201) * FIX Fix error when using Calibrated with Voting (scikit-learn#20087) * FIX Fix RandomForestRegressor doesn't accept max_samples=1.0 (scikit-learn#20159) Co-authored-by: Olivier Grisel <[email protected]> Co-authored-by: Thomas J. Fan <[email protected]> * ENH Adds Poisson criterion in RandomForestRegressor (scikit-learn#19836) Co-authored-by: Christian Lorentzen <[email protected]> Co-authored-by: Alihan Zihna <[email protected]> Co-authored-by: Alihan Zihna <[email protected]> Co-authored-by: Chiara Marmo <[email protected]> Co-authored-by: Olivier Grisel <[email protected]> Co-authored-by: naozin555 <[email protected]> Co-authored-by: Venkatachalam N <[email protected]> Co-authored-by: Thomas J. Fan <[email protected]> * TST Replace assert_warns from decomposition/tests (scikit-learn#20214) * TST check n_features_in_ in pipeline module (scikit-learn#20192) Co-authored-by: Olivier Grisel <[email protected]> Co-authored-by: Jérémie du Boisberranger <[email protected]> Co-authored-by: Olivier Grisel <[email protected]> * Allow `n_knots=None` if knots are explicitly specified in `SplineTransformer` (scikit-learn#20191) Co-authored-by: Olivier Grisel <[email protected]> * FIX make check_complex_data deterministic (scikit-learn#20221) * TST test_fit_docstring_attributes include properties (scikit-learn#20190) * FIX Uses the color max for colormap in ConfusionMatrixDisplay (scikit-learn#19784) * STY Changing .format method to f-string formatting (scikit-learn#20215) * CI Adds permissions for label action Co-authored-by: Jérémie du Boisberranger <[email protected]> Co-authored-by: tsuga <[email protected]> Co-authored-by: Conner Shen <[email protected]> Co-authored-by: Guillaume Lemaitre <[email protected]> Co-authored-by: mlondschien <[email protected]> Co-authored-by: Clément Fauchereau <[email protected]> Co-authored-by: murata-yu <[email protected]> Co-authored-by: Olivier Grisel <[email protected]> Co-authored-by: Brian Sun <[email protected]> Co-authored-by: Christian Lorentzen <[email protected]> Co-authored-by: Alihan Zihna <[email protected]> Co-authored-by: Alihan Zihna <[email protected]> Co-authored-by: Chiara Marmo <[email protected]> Co-authored-by: Olivier Grisel <[email protected]> Co-authored-by: naozin555 <[email protected]> Co-authored-by: Venkatachalam N <[email protected]> Co-authored-by: Nanshan Li <[email protected]> Co-authored-by: solosilence <[email protected]>
1 parent 6850c04 commit b87304d

31 files changed

+441
-168
lines changed

.github/workflows/labeler-title-regex.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ on:
33
pull_request_target:
44
types: [opened, edited]
55

6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
610
jobs:
711

812
labeler:

.github/workflows/wheels.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
name: Check build trigger
3737
run: bash build_tools/github/check_build_trigger.sh
3838

39-
# Build the wheels for Linux, Windows and macOS for Python 3.6 and newer
39+
# Build the wheels for Linux, Windows and macOS for Python 3.7 and newer
4040
build_wheels:
4141
name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }}-${{ matrix.manylinux_image }}
4242
runs-on: ${{ matrix.os }}
@@ -48,7 +48,7 @@ jobs:
4848
fail-fast: false
4949
matrix:
5050
os: [windows-latest, ubuntu-latest, macos-latest]
51-
python: [36, 37, 38, 39]
51+
python: [37, 38, 39]
5252
bitness: [32, 64]
5353
manylinux_image: [manylinux1, manylinux2010]
5454
include:
@@ -102,6 +102,7 @@ jobs:
102102
CIBW_TEST_REQUIRES: pytest pandas threadpoolctl
103103
CIBW_TEST_COMMAND: bash {project}/build_tools/github/test_wheels.sh
104104
CIBW_TEST_COMMAND_WINDOWS: bash {project}/build_tools/github/test_windows_wheels.sh ${{ matrix.python }} ${{ matrix.bitness }}
105+
CIBW_BUILD_VERBOSITY: 1
105106

106107
run: bash build_tools/github/build_wheels.sh
107108

benchmarks/bench_20newsgroups.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,16 @@
4646

4747
print("20 newsgroups")
4848
print("=============")
49-
print("X_train.shape = {0}".format(X_train.shape))
50-
print("X_train.format = {0}".format(X_train.format))
51-
print("X_train.dtype = {0}".format(X_train.dtype))
52-
print("X_train density = {0}"
53-
"".format(X_train.nnz / np.product(X_train.shape)))
54-
print("y_train {0}".format(y_train.shape))
55-
print("X_test {0}".format(X_test.shape))
56-
print("X_test.format = {0}".format(X_test.format))
57-
print("X_test.dtype = {0}".format(X_test.dtype))
58-
print("y_test {0}".format(y_test.shape))
49+
print(f"X_train.shape = {X_train.shape}")
50+
print(f"X_train.format = {X_train.format}")
51+
print(f"X_train.dtype = {X_train.dtype}")
52+
print(f"X_train density = {X_train.nnz / np.product(X_train.shape)}")
53+
print(f"y_train {y_train.shape}")
54+
print(f"X_test {X_test.shape}")
55+
print(f"X_test.format = {X_test.format}")
56+
print(f"X_test.dtype = {X_test.dtype}")
57+
print(f"y_test {y_test.shape}")
5958
print()
60-
6159
print("Classifier Training")
6260
print("===================")
6361
accuracy, train_time, test_time = {}, {}, {}

doc/whats_new/v1.0.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ Changelog
138138
:class:`calibration.CalibratedClassifierCV` can now properly be used on
139139
prefitted pipelines. :pr:`19641` by :user:`Alek Lefebvre <AlekLefebvre>`.
140140

141+
- |Fix| Fixed an error when using a ::class:`ensemble.VotingClassifier`
142+
as `base_estimator` in ::class:`calibration.CalibratedClassifierCV`.
143+
:pr:`20087` by :user:`Clément Fauchereau <clement-f>`.
144+
141145
:mod:`sklearn.cluster`
142146
......................
143147

@@ -266,6 +270,16 @@ Changelog
266270
:class:`ensemble.StackingClassifier` and :class:`ensemble.StackingRegressor`.
267271
:pr:`19564` by `Thomas Fan`_.
268272

273+
- |Enhancement| Documented and tested support of the Poisson criterion for
274+
:class:`ensemble.RandomForestRegressor`. :pr:`19836` by
275+
:user:`Brian Sun <bsun94>`.
276+
277+
- |Fix| Fixed the range of the argument max_samples to be (0.0, 1.0]
278+
in :class:`ensemble.RandomForestClassifier`,
279+
:class:`ensemble.RandomForestRegressor`, where `max_samples=1.0` is
280+
interpreted as using all `n_samples` for bootstrapping. :pr:`20159` by
281+
:user:`murata-yu`.
282+
269283
:mod:`sklearn.feature_extraction`
270284
.................................
271285

@@ -389,6 +403,9 @@ Changelog
389403
are integral.
390404
:pr:`9843` by :user:`Jon Crall <Erotemic>`.
391405

406+
- |Fix| :meth:`metrics.ConfusionMatrixDisplay.plot` uses the correct max
407+
for colormap. :pr:`19784` by `Thomas Fan`_.
408+
392409
- |Fix| Samples with zero `sample_weight` values do not affect the results
393410
from :func:`metrics.det_curve`, :func:`metrics.precision_recall_curve`
394411
and :func:`metrics.roc_curve`.

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ requires = [
99
# wheels on PyPI
1010
#
1111
# see: https://github.com/scipy/oldest-supported-numpy/blob/master/setup.cfg
12-
"oldest-supported-numpy",
12+
"oldest-supported-numpy; python_version!='3.7' or platform_machine=='aarch64' or platform_system=='AIX' or platform_python_implementation == 'PyPy'",
13+
14+
# Override oldest-supported-numpy setting because pandas 0.25.0 requires 1.14.6
15+
"numpy==1.14.6; python_version=='3.7' and platform_machine!='aarch64' and platform_system!='AIX' and platform_python_implementation != 'PyPy'",
1316

1417
"scipy>=1.1.0",
1518
]

sklearn/calibration.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,10 @@ def fit(self, X, y, sample_weight=None):
257257
check_is_fitted(self.base_estimator, attributes=["classes_"])
258258
self.classes_ = self.base_estimator.classes_
259259

260-
pred_method = _get_prediction_method(base_estimator)
260+
pred_method, method_name = _get_prediction_method(base_estimator)
261261
n_classes = len(self.classes_)
262-
predictions = _compute_predictions(pred_method, X, n_classes)
262+
predictions = _compute_predictions(pred_method, method_name, X,
263+
n_classes)
263264

264265
calibrated_classifier = _fit_calibrator(
265266
base_estimator, predictions, y, self.classes_, self.method,
@@ -310,12 +311,13 @@ def fit(self, X, y, sample_weight=None):
310311
)
311312
else:
312313
this_estimator = clone(base_estimator)
313-
method_name = _get_prediction_method(this_estimator).__name__
314+
_, method_name = _get_prediction_method(this_estimator)
314315
pred_method = partial(
315316
cross_val_predict, estimator=this_estimator, X=X, y=y,
316317
cv=cv, method=method_name, n_jobs=self.n_jobs
317318
)
318-
predictions = _compute_predictions(pred_method, X, n_classes)
319+
predictions = _compute_predictions(pred_method, method_name, X,
320+
n_classes)
319321

320322
if sample_weight is not None and supports_sw:
321323
this_estimator.fit(X, y, sample_weight)
@@ -441,8 +443,9 @@ def _fit_classifier_calibrator_pair(estimator, X, y, train, test, supports_sw,
441443
estimator.fit(X_train, y_train)
442444

443445
n_classes = len(classes)
444-
pred_method = _get_prediction_method(estimator)
445-
predictions = _compute_predictions(pred_method, X_test, n_classes)
446+
pred_method, method_name = _get_prediction_method(estimator)
447+
predictions = _compute_predictions(pred_method, method_name, X_test,
448+
n_classes)
446449

447450
calibrated_classifier = _fit_calibrator(
448451
estimator, predictions, y_test, classes, method, sample_weight=sw_test
@@ -465,18 +468,21 @@ def _get_prediction_method(clf):
465468
-------
466469
prediction_method : callable
467470
The prediction method.
471+
method_name : str
472+
The name of the prediction method.
468473
"""
469474
if hasattr(clf, 'decision_function'):
470475
method = getattr(clf, 'decision_function')
476+
return method, 'decision_function'
471477
elif hasattr(clf, 'predict_proba'):
472478
method = getattr(clf, 'predict_proba')
479+
return method, 'predict_proba'
473480
else:
474481
raise RuntimeError("'base_estimator' has no 'decision_function' or "
475482
"'predict_proba' method.")
476-
return method
477483

478484

479-
def _compute_predictions(pred_method, X, n_classes):
485+
def _compute_predictions(pred_method, method_name, X, n_classes):
480486
"""Return predictions for `X` and reshape binary outputs to shape
481487
(n_samples, 1).
482488
@@ -485,6 +491,9 @@ def _compute_predictions(pred_method, X, n_classes):
485491
pred_method : callable
486492
Prediction method.
487493
494+
method_name: str
495+
Name of the prediction method
496+
488497
X : array-like or None
489498
Data used to obtain predictions.
490499
@@ -498,10 +507,6 @@ def _compute_predictions(pred_method, X, n_classes):
498507
(X.shape[0], 1).
499508
"""
500509
predictions = pred_method(X=X)
501-
if hasattr(pred_method, '__name__'):
502-
method_name = pred_method.__name__
503-
else:
504-
method_name = signature(pred_method).parameters['method'].default
505510

506511
if method_name == 'decision_function':
507512
if predictions.ndim == 1:
@@ -634,8 +639,9 @@ def predict_proba(self, X):
634639
The predicted probabilities. Can be exact zeros.
635640
"""
636641
n_classes = len(self.classes)
637-
pred_method = _get_prediction_method(self.base_estimator)
638-
predictions = _compute_predictions(pred_method, X, n_classes)
642+
pred_method, method_name = _get_prediction_method(self.base_estimator)
643+
predictions = _compute_predictions(pred_method, method_name, X,
644+
n_classes)
639645

640646
label_encoder = LabelEncoder().fit(self.classes)
641647
pos_class_indices = label_encoder.transform(

sklearn/cluster/_bicluster.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ class SpectralCoclustering(BaseSpectral):
255255
column_labels_ : array-like of shape (n_cols,)
256256
The bicluster label of each column.
257257
258+
biclusters_ : tuple of two ndarrays
259+
The tuple contains the `rows_` and `columns_` arrays.
260+
258261
Examples
259262
--------
260263
>>> from sklearn.cluster import SpectralCoclustering

sklearn/compose/_column_transformer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ class ColumnTransformer(TransformerMixin, _BaseComposition):
141141
142142
.. versionadded:: 1.0
143143
144+
n_features_in_ : int
145+
Number of features seen during :term:`fit`. Only defined if the
146+
underlying transformers expose such an attribute when fit.
147+
148+
.. versionadded:: 0.24
149+
144150
Notes
145151
-----
146152
The order of the columns in the transformed feature matrix follows the

sklearn/compose/_target.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ class TransformedTargetRegressor(RegressorMixin, BaseEstimator):
8282
transformer_ : object
8383
Transformer used in ``fit`` and ``predict``.
8484
85+
n_features_in_ : int
86+
Number of features seen during :term:`fit`. Only defined if the
87+
underlying regressor exposes such an attribute when fit.
88+
89+
.. versionadded:: 0.24
90+
8591
Examples
8692
--------
8793
>>> import numpy as np

sklearn/datasets/_openml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ def fetch_openml(
840840
raise ValueError(
841841
"Dataset data_id={} and version={} passed, but you can only "
842842
"specify a numeric data_id or a version, not "
843-
"both.".format(data_id, name))
843+
"both.".format(data_id, version))
844844
else:
845845
raise ValueError(
846846
"Neither name nor data_id are provided. Please provide name or "

0 commit comments

Comments
 (0)