Version 1.4
scikit-learn Docs · نسخهٔ 5e9184e53cd3 · BSD-3-Clause
===========
Version 1.4
For a short description of the main highlights of the release, please refer to sphx_glr_auto_examples_release_highlights_plot_release_highlights_1_4_0.py.
Version 1.4.2
April 2024
This release only includes support for numpy 2.
Version 1.4.1
February 2024
Changed models
- |API| The
tree_.valueattribute intree.DecisionTreeClassifier,
tree.DecisionTreeRegressor, tree.ExtraTreeClassifier and tree.ExtraTreeRegressor changed from a weighted absolute count of number of samples to a weighted fraction of the total number of samples. 27639 by Samuel Ronsin <samronsin>.
Metadata Routing
- |FIX| Fix routing issue with
~compose.ColumnTransformerwhen used
inside another meta-estimator. 28188 by Adrin Jalali_.
- |Fix| No error is raised when no metadata is passed to a metaestimator that
includes a sub-estimator which doesn't support metadata routing. 28256 by Adrin Jalali_.
- |Fix| Fix
multioutput.MultiOutputRegressorand
multioutput.MultiOutputClassifier to work with estimators that don't consume any metadata when metadata routing is enabled. 28240 by Adrin Jalali_.
DataFrame Support
- |Enhancement| |Fix| Pandas and Polars dataframe are validated directly without
ducktyping checks. 28195 by Thomas Fan_.
Changes impacting many modules
- |Efficiency| |Fix| Partial revert of
28191to avoid a performance regression for
estimators relying on euclidean pairwise computation with sparse matrices. The impacted estimators are:
sklearn.metrics.pairwise_distances_argminsklearn.metrics.pairwise_distances_argmin_minsklearn.cluster.AffinityPropagationsklearn.cluster.Birchsklearn.cluster.SpectralClusteringsklearn.neighbors.KNeighborsClassifiersklearn.neighbors.KNeighborsRegressorsklearn.neighbors.RadiusNeighborsClassifiersklearn.neighbors.RadiusNeighborsRegressorsklearn.neighbors.LocalOutlierFactorsklearn.neighbors.NearestNeighborssklearn.manifold.Isomapsklearn.manifold.TSNEsklearn.manifold.trustworthiness
28235 by Julien Jerphanion <jjerphan>.
- |Fix| Fixes a bug for all scikit-learn transformers when using
set_outputwith
transform set to pandas or polars. The bug could lead to wrong naming of the columns of the returned dataframe. 28262 by Guillaume Lemaitre <glemaitre>.
- |Fix| When users try to use a method in
~ensemble.StackingClassifier,
~ensemble.StackingClassifier, ~ensemble.StackingClassifier, ~feature_selection.SelectFromModel, ~feature_selection.RFE, ~semi_supervised.SelfTrainingClassifier, ~multiclass.OneVsOneClassifier, ~multiclass.OutputCodeClassifier or ~multiclass.OneVsRestClassifier that their sub-estimators don't implement, the AttributeError now reraises in the traceback. 28167 by Stefanie Senger <StefanieSenger>.
Changelog
sklearn.calibration ..........................
- |Fix|
calibration.CalibratedClassifierCVsupportspredict_probawith
float32 output from the inner estimator. 28247 by Thomas Fan_.
sklearn.cluster ......................
- |Fix|
cluster.AffinityPropagationnow avoids assigning multiple different
clusters for equal points. 28121 by Pietro Peterlongo <pietroppeter> and Yao Xiao <Charlie-XIAO>.
- |Fix| Avoid infinite loop in
cluster.KMeanswhen the number of clusters is
larger than the number of non-duplicate samples. 28165 by Jérémie du Boisberranger <jeremiedbb>.
sklearn.compose ......................
- |Fix|
compose.ColumnTransformernow transforms into a polars dataframe when
verbose_feature_names_out=True and the transformers internally used several times the same columns. Previously, it would raise a due to duplicated column names. 28262 by Guillaume Lemaitre <glemaitre>.
sklearn.ensemble .......................
- |Fix|
HistGradientBoostingClassifierand
HistGradientBoostingRegressor when fitted on pandas DataFrame with extension dtypes, for example pd.Int64Dtype 28385 by Loïc Estève <lesteve>.
- |Fix| Fixes error message raised by
ensemble.VotingClassifierwhen the
target is multilabel or multiclass-multioutput in a DataFrame format. 27702 by Guillaume Lemaitre <glemaitre>.
sklearn.impute .....................
- |Fix|:
impute.SimpleImputernow raises an error in.fitand
.transform if fill_value can not be cast to input value dtype with casting='same_kind'. 28365 by Leo Grinsztajn <LeoGrin>.
sklearn.inspection .........................
- |Fix|
inspection.permutation_importancenow handles properlysample_weight
together with subsampling (i.e. max_features < 1.0). 28184 by Michael Mayer <mayer79>.
sklearn.linear_model ...........................
- |Fix|
linear_model.ARDRegressionnow handles pandas input types
for predict(X, return_std=True). 28377 by Eddie Bergman <eddiebergman>.
sklearn.preprocessing ............................
- |Fix| make
preprocessing.FunctionTransformermore lenient and overwrite
output column names with the get_feature_names_out in the following cases: (i) the input and output column names remain the same (happen when using NumPy ufunc); (ii) the input column names are numbers; (iii) the output will be set to Pandas or Polars dataframe. 28241 by Guillaume Lemaitre <glemaitre>.
- |Fix|
preprocessing.FunctionTransformernow also warns whenset_output
is called with transform="polars" and func does not return a Polars dataframe or feature_names_out is not specified. 28263 by Guillaume Lemaitre <glemaitre>.
- |Fix|
preprocessing.TargetEncoderno longer fails when
target_type="continuous" and the input is read-only. In particular, it now works with pandas copy-on-write mode enabled. 28233 by John Hopfensperger <s-banach>.
sklearn.tree ...................
- |Fix|
tree.DecisionTreeClassifierand
tree.DecisionTreeRegressor are handling missing values properly. The internal criterion was not initialized when no missing values were present in the data, leading to potentially wrong criterion values. 28295 by Guillaume Lemaitre <glemaitre> and 28327 by Adam Li <adam2392>.
sklearn.utils ....................
- |Enhancement| |Fix|
utils.metaestimators.available_ifnow reraises the error
from the check function as the cause of the AttributeError. 28198 by Thomas Fan_.
- |Fix|
utils._safe_indexingnow raises aValueErrorwhenXis a Python list
and axis=1, as documented in the docstring. 28222 by Guillaume Lemaitre <glemaitre>.
Version 1.4.0
January 2024
Changed models
The following estimators and functions, when fit with the same data and parameters, may produce different models from the previous version. This often occurs due to changes in the modelling logic (bug fixes or enhancements), or in random sampling procedures.
- |Efficiency|
linear_model.LogisticRegressionand
linear_model.LogisticRegressionCV now have much better convergence for solvers "lbfgs" and "newton-cg". Both solvers can now reach much higher precision for the coefficients depending on the specified tol. Additionally, lbfgs can make better use of tol, i.e., stop sooner or reach higher precision. Note: The lbfgs is the default solver, so this change might affect many models. This change also means that with this new version of scikit-learn, the resulting coefficients coef_ and intercept_ of your models will change for these two solvers (when fit on the same data again). The amount of change depends on the specified tol, for small values you will get more precise results. 26721 by Christian Lorentzen <lorentzenchr>.
- |Fix| fixes a memory leak seen in PyPy for estimators using the Cython loss functions.
27670 by Guillaume Lemaitre <glemaitre>.
Changes impacting all modules
- |MajorFeature| Transformers now support polars output with
set_output(transform="polars"). 27315 by Thomas Fan_.
- |Enhancement| All estimators now recognize the column names from any dataframe
that adopts the DataFrame Interchange Protocol <https://data-apis.org/dataframe-protocol/latest/purpose_and_scope.html>__. Dataframes that return a correct representation through np.asarray(df) is expected to work with our estimators and functions. 26464 by Thomas Fan_.
- |Enhancement| The HTML representation of estimators now includes a link to the
documentation and is color-coded to denote whether the estimator is fitted or not (unfitted estimators are orange, fitted estimators are blue). 26616 by Riccardo Cappuzzo <rcap107>, Ines Ibnukhsein <Ines1999>, Gael Varoquaux <GaelVaroquaux>, Joel Nothman_ and Lilian Boulard <LilianBoulard>.
- |Fix| Fixed a bug in most estimators and functions where setting a parameter to
a large integer would cause a TypeError. 26648 by Naoise Holohan <naoise-h>.
Metadata Routing
The following models now support metadata routing in one or more of their methods. Refer to the Metadata Routing User Guide <metadata_routing> for more details.
- |Feature|
LarsCVandLassoLarsCVnow support metadata
routing in their fit method and route metadata to the CV splitter. 27538 by Omar Salman <OmarManzoor>.
- |Feature|
multiclass.OneVsRestClassifier,
multiclass.OneVsOneClassifier and multiclass.OutputCodeClassifier now support metadata routing in their `fit and partial_fit, and route metadata to the underlying estimator's fit and partial_fit. 27308 by Stefanie Senger <StefanieSenger>`.
- |Feature|
pipeline.Pipelinenow supports metadata routing according
to metadata routing user guide <metadata_routing>. 26789 by Adrin Jalali_.
- |Feature|
~model_selection.cross_validate,
~model_selection.cross_val_score, and ~model_selection.cross_val_predict now support metadata routing. The metadata are routed to the estimator's fit, the scorer, and the CV splitter's split. The metadata is accepted via the new params parameter. fit_params is deprecated and will be removed in version 1.6. groups parameter is also not accepted as a separate argument when metadata routing is enabled and should be passed via the params parameter. 26896 by Adrin Jalali_.
- |Feature|
~model_selection.GridSearchCV,
~model_selection.RandomizedSearchCV, ~model_selection.HalvingGridSearchCV, and ~model_selection.HalvingRandomSearchCV now support metadata routing in their `fit and score, and route metadata to the underlying estimator's fit, the CV splitter, and the scorer. 27058 by Adrin Jalali`_.
- |Feature|
~compose.ColumnTransformernow supports metadata routing
according to metadata routing user guide <metadata_routing>. 27005 by Adrin Jalali_.
- |Feature|
linear_model.LogisticRegressionCVnow supports
metadata routing. linear_model.LogisticRegressionCV.fit now accepts `**params which are passed to the underlying splitter and scorer. linear_model.LogisticRegressionCV.score now accepts **score_params which are passed to the underlying scorer. 26525 by Omar Salman <OmarManzoor>`.
- |Feature|
feature_selection.SelectFromModelnow supports metadata
routing in fit and partial_fit. 27490 by Stefanie Senger <StefanieSenger>.
- |Feature|
linear_model.OrthogonalMatchingPursuitCVnow supports
metadata routing. Its fit now accepts `**fit_params, which are passed to the underlying splitter. 27500 by Stefanie Senger <StefanieSenger>`.
- |Feature|
ElasticNetCV,LassoCV,
MultiTaskElasticNetCV and MultiTaskLassoCV now support metadata routing and route metadata to the CV splitter. 27478 by Omar Salman <OmarManzoor>.
- |Fix| All meta-estimators for which metadata routing is not yet implemented
now raise a NotImplementedError on get_metadata_routing and on fit if metadata routing is enabled and any metadata is passed to them. 27389 by Adrin Jalali_.
Support for SciPy sparse arrays
Several estimators are now supporting SciPy sparse arrays. The following functions and classes are impacted:
Functions:
cluster.compute_optics_graphin27104by
Maren Westermann <marenwestermann> and in 27250 by Yao Xiao <Charlie-XIAO>;
cluster.kmeans_plusplusin27179byNurseit Kamchyev <Bncer>;decomposition.non_negative_factorizationin27100by
Isaac Virshup <ivirshup>;
feature_selection.f_regressionin27239by
Yaroslav Korobko <Tialo>;
feature_selection.r_regressionin27239by
Yaroslav Korobko <Tialo>;
manifold.trustworthinessin27250byYao Xiao <Charlie-XIAO>;manifold.spectral_embeddingin27240byYao Xiao <Charlie-XIAO>;metrics.pairwise_distancesin27250byYao Xiao <Charlie-XIAO>;metrics.pairwise_distances_chunkedin27250by
Yao Xiao <Charlie-XIAO>;
metrics.pairwise.pairwise_kernelsin27250by
Yao Xiao <Charlie-XIAO>;
utils.multiclass.type_of_targetin27274by
Yao Xiao <Charlie-XIAO>.
Classes:
cluster.HDBSCANin27250byYao Xiao <Charlie-XIAO>;cluster.KMeansin27179byNurseit Kamchyev <Bncer>;cluster.MiniBatchKMeansin27179byNurseit Kamchyev <Bncer>;cluster.OPTICSin27104by
Maren Westermann <marenwestermann> and in 27250 by Yao Xiao <Charlie-XIAO>;
cluster.SpectralClusteringin27161by
Bharat Raghunathan <bharatr21>;
decomposition.MiniBatchNMFin27100by
Isaac Virshup <ivirshup>;
decomposition.NMFin27100byIsaac Virshup <ivirshup>;feature_extraction.text.TfidfTransformerin27219by
Yao Xiao <Charlie-XIAO>;
manifold.Isomapin27250byYao Xiao <Charlie-XIAO>;manifold.SpectralEmbeddingin27240byYao Xiao <Charlie-XIAO>;manifold.TSNEin27250byYao Xiao <Charlie-XIAO>;impute.SimpleImputerin27277byYao Xiao <Charlie-XIAO>;impute.IterativeImputerin27277byYao Xiao <Charlie-XIAO>;impute.KNNImputerin27277byYao Xiao <Charlie-XIAO>;kernel_approximation.PolynomialCountSketchin27301by
Lohit SundaramahaLingam <lohitslohit>;
neural_network.BernoulliRBMin27252by
Yao Xiao <Charlie-XIAO>;
preprocessing.PolynomialFeaturesin27166by
Mohit Joshi <work-mohit>;
random_projection.GaussianRandomProjectionin27314by
Stefanie Senger <StefanieSenger>;
random_projection.SparseRandomProjectionin27314by
Stefanie Senger <StefanieSenger>.
Support for Array API
Several estimators and functions support the Array API <https://data-apis.org/array-api/latest/>_. Such changes allow for using the estimators and functions with other libraries such as JAX, CuPy, and PyTorch. This therefore enables some GPU-accelerated computations.
See array_api for more details.
Functions:
sklearn.metrics.accuracy_scoreandsklearn.metrics.zero_one_lossin
27137 by Edoardo Abati <EdAbati>;
sklearn.model_selection.train_test_splitin26855byTim Head_;~utils.multiclass.is_multilabelin27601by
Yaroslav Korobko <Tialo>.
Classes:
decomposition.PCAfor thefullandrandomizedsolvers (with QR power
iterations) in 26315, 27098 and 27431 by Mateusz Sokół <mtsokol>, Olivier Grisel <ogrisel> and Edoardo Abati <EdAbati>;
preprocessing.KernelCentererin27556by
Edoardo Abati <EdAbati>;
preprocessing.MaxAbsScalerin27110byEdoardo Abati <EdAbati>;preprocessing.MinMaxScalerin26243byTim Head_;preprocessing.Normalizerin27558byEdoardo Abati <EdAbati>.
Private Loss Function Module
- |FIX| The gradient computation of the binomial log loss is now numerically
more stable for very large, in absolute value, input (raw predictions). Before, it could result in np.nan. Among the models that profit from this change are ensemble.GradientBoostingClassifier, ensemble.HistGradientBoostingClassifier and linear_model.LogisticRegression. 28048 by Christian Lorentzen <lorentzenchr>.
Changelog
.. Entries should be grouped by module (in alphabetic order) and prefixed with one of the labels: |MajorFeature|, |Feature|, |Efficiency|, |Enhancement|,
| Fix | or | API | (see whats_new.rst for descriptions). |
Entries should be ordered by those labels (e.g. |Fix| after |Efficiency|). Changes not specific to a module should be listed under *Multiple Modules* or *Miscellaneous*. Entries should end with: 123456 by Joe Bloggs <joeongithub>. where 123455 is the *pull request* number, not the issue number.
sklearn.base ...................
- |Enhancement|
base.ClusterMixin.fit_predictand
base.OutlierMixin.fit_predict now accept `**kwargs which are passed to the fit method of the estimator. 26506 by Adrin Jalali`_.
- |Enhancement|
base.TransformerMixin.fit_transformand
base.OutlierMixin.fit_predict now raise a warning if `transform / predict consume metadata, but no custom fit_transform / fit_predict is defined in the class inheriting from them correspondingly. 26831 by Adrin Jalali`_.
- |Enhancement|
base.clonenow supportsdictas input and creates a
copy. 26786 by Adrin Jalali_.
- |API|
~utils.metadata_routing.process_routingnow has a different
signature. The first two (the object and the method) are positional only, and all metadata are passed as keyword arguments. 26909 by Adrin Jalali_.
sklearn.calibration ..........................
- |Enhancement| The internal objective and gradient of the
sigmoidmethod
of calibration.CalibratedClassifierCV have been replaced by the private loss module. 27185 by Omar Salman <OmarManzoor>.
sklearn.cluster ......................
- |Fix| The
degreeparameter in thecluster.SpectralClustering
constructor now accepts real values instead of only integral values in accordance with the degree parameter of the sklearn.metrics.pairwise.polynomial_kernel. 27668 by Nolan McMahon <NolantheNerd>.
- |Fix| Fixes a bug in
cluster.OPTICSwhere the cluster correction based
on predecessor was not using the right indexing. It would lead to inconsistent results dependent on the order of the data. 26459 by Haoying Zhang <stevezhang1999> and Guillaume Lemaitre <glemaitre>.
- |Fix| Improve error message when checking the number of connected components
in the fit method of cluster.HDBSCAN. 27678 by Ganesh Tata <tataganesh>.
- |Fix| Create copy of precomputed sparse matrix within the
fit method of cluster.DBSCAN to avoid in-place modification of the sparse matrix. 27651 by Ganesh Tata <tataganesh>.
- |Fix| Raises a proper
ValueErrorwhenmetric="precomputed"and requested storing
centers via the parameter store_centers. 27898 by Guillaume Lemaitre <glemaitre>.
- |API|
kdtreeandballtreevalues are now deprecated and are renamed as
kd_tree and ball_tree respectively for the algorithm parameter of cluster.HDBSCAN ensuring consistency in naming convention. kdtree and balltree values will be removed in 1.6. 26744 by Shreesha Kumar Bhat <Shreesha3112>.
- |API| The option
metric=Nonein
cluster.AgglomerativeClustering and cluster.FeatureAgglomeration is deprecated in version 1.4 and will be removed in version 1.6. Use the default value instead. 27828 by Guillaume Lemaitre <glemaitre>.
sklearn.compose ......................
- |MajorFeature| Adds
polars <https://www.pola.rs>__ input support to
compose.ColumnTransformer through the DataFrame Interchange Protocol <https://data-apis.org/dataframe-protocol/latest/purpose_and_scope.html>__. The minimum supported version for polars is 0.19.12. 26683 by Thomas Fan_.
- |Fix|
cluster.spectral_clusteringandcluster.SpectralClustering
now raise an explicit error message indicating that sparse matrices and arrays with np.int64 indices are not supported. 27240 by Yao Xiao <Charlie-XIAO>.
- |API| outputs that use pandas extension dtypes and contain
pd.NAin
~compose.ColumnTransformer now result in a FutureWarning and will cause a ValueError in version 1.6, unless the output container has been configured as "pandas" with set_output(transform="pandas"). Before, such outputs resulted in numpy arrays of dtype object containing pd.NA which could not be converted to numpy floats and caused errors when passed to other scikit-learn estimators. 27734 by Jérôme Dockès <jeromedockes>.
sklearn.covariance .........................
- |Enhancement| Allow
covariance.shrunk_covarianceto process
multiple covariance matrices at once by handling nd-arrays. 25275 by Quentin Barthélemy <qbarthelemy>.
- |API| |FIX|
~compose.ColumnTransformernow replaces"passthrough"
with a corresponding ~preprocessing.FunctionTransformer in the fitted `transformers_ attribute. 27204 by Adrin Jalali`_.
sklearn.datasets .......................
- |Enhancement|
datasets.make_sparse_spd_matrixnow uses a more memory-efficient
sparse layout. It also accepts a new keyword sparse_format that allows specifying the output format of the sparse matrix. By default sparse_format=None, which returns a dense numpy ndarray as before. 27438 by Yao Xiao <Charlie-XIAO>.
- |Fix|
datasets.dump_svmlight_filenow does not raiseValueErrorwhenX
is read-only, e.g., a numpy.memmap instance. 28111 by Yao Xiao <Charlie-XIAO>.
- |API|
datasets.make_sparse_spd_matrixdeprecated the keyword argument `dim`
in favor of `n_dim. dim will be removed in version 1.6. 27718 by Adam Li <adam2392>`.
sklearn.decomposition ............................
- |Feature|
decomposition.PCAnow supportsscipy.sparse.sparray
and scipy.sparse.spmatrix inputs when using the arpack solver. When used on sparse data like datasets.fetch_20newsgroups_vectorized this can lead to speed-ups of 100x (single threaded) and 70x lower memory usage. Based on Alexander Tarashansky <atarashansky>'s implementation in scanpy <https://github.com/scverse/scanpy>_. 18689 by Isaac Virshup <ivirshup> and Andrey Portnoy <andportnoy>.
- |Enhancement| An "auto" option was added to the
n_componentsparameter of
decomposition.non_negative_factorization, decomposition.NMF and decomposition.MiniBatchNMF to automatically infer the number of components from W or H shapes when using a custom initialization. The default value of this parameter will change from None to auto in version 1.6. 26634 by Alexandre Landeau <AlexL> and Alexandre Vigny <avigny>.
- |Fix|
decomposition.dict_learning_onlinedoes not ignore anymore the parameter
max_iter. 27834 by Guillaume Lemaitre <glemaitre>.
- |Fix| The
degreeparameter in thedecomposition.KernelPCA
constructor now accepts real values instead of only integral values in accordance with the degree parameter of the sklearn.metrics.pairwise.polynomial_kernel. 27668 by Nolan McMahon <NolantheNerd>.
- |API| The option
max_iter=Nonein
decomposition.MiniBatchDictionaryLearning, decomposition.MiniBatchSparsePCA, and decomposition.dict_learning_online is deprecated and will be removed in version 1.6. Use the default value instead. 27834 by Guillaume Lemaitre <glemaitre>.
sklearn.ensemble .......................
- |MajorFeature|
ensemble.RandomForestClassifierand
ensemble.RandomForestRegressor support missing values when the criterion is gini, entropy, or log_loss, for classification or squared_error, friedman_mse, or poisson for regression. 26391 by Thomas Fan_.
- |MajorFeature|
ensemble.HistGradientBoostingClassifierand
ensemble.HistGradientBoostingRegressor support categorical_features="from_dtype", which treats columns with Pandas or Polars Categorical dtype as categories in the algorithm. categorical_features="from_dtype" will become the default in v1.6. Categorical features no longer need to be encoded with numbers. When categorical features are numbers, the maximum value no longer needs to be smaller than max_bins; only the number of (unique) categories must be smaller than max_bins. 26411 by Thomas Fan_ and 27835 by Jérôme Dockès <jeromedockes>.
- |MajorFeature|
ensemble.HistGradientBoostingClassifierand
ensemble.HistGradientBoostingRegressor got the new parameter max_features to specify the proportion of randomly chosen features considered in each split. 27139 by Christian Lorentzen <lorentzenchr>.
- |Feature|
ensemble.RandomForestClassifier,
ensemble.RandomForestRegressor, ensemble.ExtraTreesClassifier and ensemble.ExtraTreesRegressor now support monotonic constraints, useful when features are supposed to have a positive/negative effect on the target. Missing values in the train data and multi-output targets are not supported. 13649 by Samuel Ronsin <samronsin>, initiated by Patrick O'Reilly <pat-oreilly>.
- |Efficiency|
ensemble.HistGradientBoostingClassifierand
ensemble.HistGradientBoostingRegressor are now a bit faster by reusing the parent node's histogram as children node's histogram in the subtraction trick. In effect, less memory has to be allocated and deallocated. 27865 by Christian Lorentzen <lorentzenchr>.
- |Efficiency|
ensemble.GradientBoostingClassifieris faster,
for binary and in particular for multiclass problems thanks to the private loss function module. 26278 and 28095 by Christian Lorentzen <lorentzenchr>.
- |Efficiency| Improves runtime and memory usage for
ensemble.GradientBoostingClassifier and ensemble.GradientBoostingRegressor when trained on sparse data. 26957 by Thomas Fan_.
- |Efficiency|
ensemble.HistGradientBoostingClassifierand
ensemble.HistGradientBoostingRegressor is now faster when scoring is a predefined metric listed in metrics.get_scorer_names and early stopping is enabled. 26163 by Thomas Fan_.
- |Enhancement| A fitted property, `
estimators_samples_`, was added to all Forest
methods, including ensemble.RandomForestClassifier, ensemble.RandomForestRegressor, ensemble.ExtraTreesClassifier and ensemble.ExtraTreesRegressor, which allows to retrieve the training sample indices used for each tree estimator. 26736 by Adam Li <adam2392>.
- |Fix| Fixes
ensemble.IsolationForestwhen the input is a sparse matrix and
contamination is set to a float value. 27645 by Guillaume Lemaitre <glemaitre>.
- |Fix| Raises a
ValueErrorinensemble.RandomForestRegressorand
ensemble.ExtraTreesRegressor when requesting OOB score with multioutput model for the targets being all rounded to integer. It was recognized as a multiclass problem. 27817 by Daniele Ongari <danieleongari>
- |Fix| Changes estimator tags to acknowledge that
ensemble.VotingClassifier, ensemble.VotingRegressor, ensemble.StackingClassifier, ensemble.StackingRegressor, support missing values if all estimators support missing values. 27710 by Guillaume Lemaitre <glemaitre>.
- |Fix| Support loading pickles of
ensemble.HistGradientBoostingClassifierand
ensemble.HistGradientBoostingRegressor when the pickle has been generated on a platform with a different bitness. A typical example is to train and pickle the model on 64 bit machine and load the model on a 32 bit machine for prediction. 28074 by Christian Lorentzen <lorentzenchr> and Loïc Estève <lesteve>.
- |API| In
ensemble.AdaBoostClassifier, thealgorithmargumentSAMME.Rwas
deprecated and will be removed in 1.6. 26830 by Stefanie Senger <StefanieSenger>.
sklearn.feature_extraction .................................
- |API| Changed error type from
AttributeErrorto
exceptions.NotFittedError in unfitted instances of feature_extraction.DictVectorizer for the following methods: feature_extraction.DictVectorizer.inverse_transform, feature_extraction.DictVectorizer.restrict, feature_extraction.DictVectorizer.transform. 24838 by Lorenz Hertel <LoHertel>.
sklearn.feature_selection ................................
- |Enhancement|
feature_selection.SelectKBest,
feature_selection.SelectPercentile, and feature_selection.GenericUnivariateSelect now support unsupervised feature selection by providing a score_func taking X and y=None. 27721 by Guillaume Lemaitre <glemaitre>.
- |Enhancement|
feature_selection.SelectKBestand
feature_selection.GenericUnivariateSelect with mode='k_best' now shows a warning when k is greater than the number of features. 27841 by Thomas Fan_.
- |Fix|
feature_selection.RFEandfeature_selection.RFECVdo
not check for nans during input validation. 21807 by Thomas Fan_.
sklearn.inspection .........................
- |Enhancement|
inspection.DecisionBoundaryDisplaynow accepts a parameter
class_of_interest to select the class of interest when plotting the response provided by response_method="predict_proba" or response_method="decision_function". It allows to plot the decision boundary for both binary and multiclass classifiers. 27291 by Guillaume Lemaitre <glemaitre>.
- |Fix|
inspection.DecisionBoundaryDisplay.from_estimatorand
inspection.PartialDependenceDisplay.from_estimator now return the correct type for subclasses. 27675 by John Cant <johncant>.
- |API|
inspection.DecisionBoundaryDisplayraises anAttributeErrorinstead
of a ValueError when an estimator does not implement the requested response method. 27291 by Guillaume Lemaitre <glemaitre>.
sklearn.kernel_ridge ...........................
- |Fix| The
degreeparameter in thekernel_ridge.KernelRidge
constructor now accepts real values instead of only integral values in accordance with the degree parameter of the sklearn.metrics.pairwise.polynomial_kernel. 27668 by Nolan McMahon <NolantheNerd>.
sklearn.linear_model ...........................
- |Efficiency|
linear_model.LogisticRegressionand
linear_model.LogisticRegressionCV now have much better convergence for solvers "lbfgs" and "newton-cg". Both solvers can now reach much higher precision for the coefficients depending on the specified tol. Additionally, lbfgs can make better use of tol, i.e., stop sooner or reach higher precision. This is accomplished by better scaling of the objective function, i.e., using average per sample losses instead of sum of per sample losses. 26721 by Christian Lorentzen <lorentzenchr>.
- |Efficiency|
linear_model.LogisticRegressionand
linear_model.LogisticRegressionCV with solver "newton-cg" can now be considerably faster for some data and parameter settings. This is accomplished by a better line search convergence check for negligible loss improvements that takes into account gradient information. 26721 by Christian Lorentzen <lorentzenchr>.
- |Efficiency| Solver
"newton-cg"inlinear_model.LogisticRegressionand
linear_model.LogisticRegressionCV uses a little less memory. The effect is proportional to the number of coefficients (n_features * n_classes). 27417 by Christian Lorentzen <lorentzenchr>.
- |Fix| Ensure that the
sigma_attribute of
linear_model.ARDRegression and linear_model.BayesianRidge always has a float32 dtype when fitted on float32 data, even with the type promotion rules of NumPy 2. 27899 by Olivier Grisel <ogrisel>.
- |API| The attribute
loss_function_oflinear_model.SGDClassifierand
linear_model.SGDOneClassSVM has been deprecated and will be removed in version 1.6. 27979 by Christian Lorentzen <lorentzenchr>.
sklearn.metrics ......................
- |Efficiency| Computing pairwise distances via
metrics.DistanceMetric
for CSR x CSR, Dense x CSR, and CSR x Dense datasets is now 1.5x faster. 26765 by Meekail Zain <micky774>.
- |Efficiency| Computing distances via
metrics.DistanceMetric
for CSR x CSR, Dense x CSR, and CSR x Dense now uses ~50% less memory, and outputs distances in the same dtype as the provided data. 27006 by Meekail Zain <micky774>.
- |Enhancement| Improve the rendering of the plot obtained with the
metrics.PrecisionRecallDisplay and metrics.RocCurveDisplay classes. The x- and y-axis limits are set to [0, 1] and the aspect ratio between both axes is set to be 1 to get a square plot. 26366 by Mojdeh Rastgoo <mrastgoo>.
- |Enhancement| Added
neg_root_mean_squared_log_error_scoreras scorer
26734 by Alejandro Martin Gil <101AlexMartin>.
- |Enhancement|
metrics.confusion_matrixnow warns when only one label was
found in y_true and y_pred. 27650 by Lucy Liu <lucyleeow>.
- |Fix| computing pairwise distances with
metrics.pairwise.euclidean_distances
no longer raises an exception when X is provided as a float64 array and X_norm_squared as a float32 array. 27624 by Jérôme Dockès <jeromedockes>.
- |Fix|
f1_scorenow provides correct values when handling various
cases in which division by zero occurs by using a formulation that does not depend on the precision and recall values. 27577 by Omar Salman <OmarManzoor> and Guillaume Lemaitre <glemaitre>.
- |Fix|
metrics.make_scorernow raises an error when using a regressor on a
scorer requesting a non-thresholded decision function (from decision_function or predict_proba). Such scorers are specific to classification. 26840 by Guillaume Lemaitre <glemaitre>.
- |Fix|
metrics.DetCurveDisplay.from_predictions,
metrics.PrecisionRecallDisplay.from_predictions, metrics.PredictionErrorDisplay.from_predictions, and metrics.RocCurveDisplay.from_predictions now return the correct type for subclasses. 27675 by John Cant <johncant>.
- |API| Deprecated
needs_thresholdandneeds_probafrommetrics.make_scorer.
These parameters will be removed in version 1.6. Instead, use response_method that accepts "predict", "predict_proba" or "decision_function" or a list of such values. needs_proba=True is equivalent to response_method="predict_proba" and needs_threshold=True is equivalent to response_method=("decision_function", "predict_proba"). 26840 by Guillaume Lemaitre <glemaitre>.
- |API| The
squaredparameter ofmetrics.mean_squared_errorand
metrics.mean_squared_log_error is deprecated and will be removed in 1.6. Use the new functions metrics.root_mean_squared_error and metrics.root_mean_squared_log_error instead. 26734 by Alejandro Martin Gil <101AlexMartin>.
sklearn.model_selection ..............................
- |Enhancement|
model_selection.learning_curveraises a warning when
every cross validation fold fails. 26299 by Rahil Parikh <rprkh>.
- |Fix|
model_selection.GridSearchCV,
model_selection.RandomizedSearchCV, and model_selection.HalvingGridSearchCV now don't change the given object in the parameter grid if it's an estimator. 26786 by Adrin Jalali_.
sklearn.multioutput ..........................
- |Enhancement| Add method
predict_log_probatomultioutput.ClassifierChain.
27720 by Guillaume Lemaitre <glemaitre>.
sklearn.neighbors ........................
- |Efficiency|
sklearn.neighbors.KNeighborsRegressor.predictand
sklearn.neighbors.KNeighborsClassifier.predict_proba now efficiently support pairs of dense and sparse datasets. 27018 by Julien Jerphanion <jjerphan>.
- |Efficiency| The performance of
neighbors.RadiusNeighborsClassifier.predict
and of neighbors.RadiusNeighborsClassifier.predict_proba has been improved when radius is large and algorithm="brute" with non-Euclidean metrics. 26828 by Omar Salman <OmarManzoor>.
- |Fix| Improve error message for
neighbors.LocalOutlierFactor
when it is invoked with n_samples=n_neighbors. 23317 by Bharat Raghunathan <bharatr21>.
- |Fix|
neighbors.KNeighborsClassifier.predictand
neighbors.KNeighborsClassifier.predict_proba now raise an error when the weights of all neighbors of some sample are zero. This can happen when weights is a user-defined function. 26410 by Yao Xiao <Charlie-XIAO>.
- |API|
neighbors.KNeighborsRegressornow accepts
metrics.DistanceMetric objects directly via the metric keyword argument allowing for the use of accelerated third-party metrics.DistanceMetric objects. 26267 by Meekail Zain <micky774>.
sklearn.preprocessing ............................
- |Efficiency|
preprocessing.OrdinalEncoderavoids calculating
missing indices twice to improve efficiency. 27017 by Xuefeng Xu <xuefeng-xu>.
- |Efficiency| Improves efficiency in
preprocessing.OneHotEncoderand
preprocessing.OrdinalEncoder in checking nan. 27760 by Xuefeng Xu <xuefeng-xu>.
- |Enhancement| Improves warnings in
preprocessing.FunctionTransformerwhen
func returns a pandas dataframe and the output is configured to be pandas. 26944 by Thomas Fan_.
- |Enhancement|
preprocessing.TargetEncodernow supportstarget_type
'multiclass'. 26674 by Lucy Liu <lucyleeow>.
- |Fix|
preprocessing.OneHotEncoderandpreprocessing.OrdinalEncoder
raise an exception when nan is a category and is not the last in the user's provided categories. 27309 by Xuefeng Xu <xuefeng-xu>.
- |Fix|
preprocessing.OneHotEncoderandpreprocessing.OrdinalEncoder
raise an exception if the user provided categories contain duplicates. 27328 by Xuefeng Xu <xuefeng-xu>.
- |Fix|
preprocessing.FunctionTransformerraises an error attransformif
the output of get_feature_names_out is not consistent with the column names of the output container if those are defined. 27801 by Guillaume Lemaitre <glemaitre>.
- |Fix| Raise a
NotFittedErrorinpreprocessing.OrdinalEncoderwhen calling
transform without calling fit since categories always requires to be checked. 27821 by Guillaume Lemaitre <glemaitre>.
sklearn.tree ...................
- |Feature|
tree.DecisionTreeClassifier,tree.DecisionTreeRegressor,
tree.ExtraTreeClassifier and tree.ExtraTreeRegressor now support monotonic constraints, useful when features are supposed to have a positive/negative effect on the target. Missing values in the train data and multi-output targets are not supported. 13649 by Samuel Ronsin <samronsin>, initiated by Patrick O'Reilly <pat-oreilly>.
sklearn.utils ....................
- |Enhancement|
sklearn.utils.estimator_html_reprdynamically adapts
diagram colors based on the browser's prefers-color-scheme, providing improved adaptability to dark mode environments. 26862 by Andrew Goh Yisheng <9y5>, Thomas Fan_, Adrin Jalali_.
- |Enhancement|
~utils.metadata_routing.MetadataRequestand
~utils.metadata_routing.MetadataRouter now have a `consumes method which can be used to check whether a given set of parameters would be consumed. 26831 by Adrin Jalali`_.
- |Enhancement| Make
sklearn.utils.check_arrayattempt to output
int32-indexed CSR and COO arrays when converting from DIA arrays if the number of non-zero entries is small enough. This ensures that estimators implemented in Cython and that do not accept int64-indexed sparse datastucture, now consistently accept the same sparse input formats for SciPy sparse matrices and arrays. 27372 by Guillaume Lemaitre <glemaitre>.
- |Fix|
sklearn.utils.check_arrayshould accept both matrix and array from
the sparse SciPy module. The previous implementation would fail if copy=True by calling specific NumPy np.may_share_memory that does not work with SciPy sparse array and does not return the correct result for SciPy sparse matrix. 27336 by Guillaume Lemaitre <glemaitre>.
- |Fix|
~utils.estimator_checks.check_estimators_picklewith
readonly_memmap=True now relies on joblib's own capability to allocate aligned memory mapped arrays when loading a serialized estimator instead of calling a dedicated private function that would crash when OpenBLAS misdetects the CPU architecture. 27614 by Olivier Grisel <ogrisel>.
- |Fix| Error message in
~utils.check_arraywhen a sparse matrix was
passed but accept_sparse is False now suggests to use .toarray() and not X.toarray(). 27757 by Lucy Liu <lucyleeow>.
- |Fix| Fix the function
~utils.check_arrayto output the right error message
when the input is a Series instead of a DataFrame. 28090 by Stan Furrer <stanFurrer> and Yao Xiao <Charlie-XIAO>.
- |API|
sklearn.utils.extmath.log_logisticis deprecated and will be removed in 1.6.
Use -np.logaddexp(0, -x) instead. 27544 by Christian Lorentzen <lorentzenchr>.
Thanks to everyone who has contributed to the maintenance and improvement of the project since version 1.3, including:
101AlexMartin, Abhishek Singh Kushwah, Adam Li, Adarsh Wase, Adrin Jalali, Advik Sinha, Alex, Alexander Al-Feghali, Alexis IMBERT, AlexL, Alex Molas, Anam Fatima, Andrew Goh, andyscanzio, Aniket Patil, Artem Kislovskiy, Arturo Amor, ashah002, avm19, Ben Holmes, Ben Mares, Benoit Chevallier-Mames, Bharat Raghunathan, Binesh Bannerjee, Brendan Lu, Brevin Kunde, Camille Troillard, Carlo Lemos, Chad Parmet, Christian Clauss, Christian Lorentzen, Christian Veenhuis, Christos Aridas, Cindy Liang, Claudio Salvatore Arcidiacono, Connor Boyle, cynthias13w, DaminK, Daniele Ongari, Daniel Schmitz, Daniel Tinoco, David Brochart, Deborah L. Haar, DevanshKyada27, Dimitri Papadopoulos Orfanos, Dmitry Nesterov, DUONG, Edoardo Abati, Eitan Hemed, Elabonga Atuo, Elisabeth Günther, Emma Carballal, Emmanuel Ferdman, epimorphic, Erwan Le Floch, Fabian Egli, Filip Karlo Došilović, Florian Idelberger, Franck Charras, Gael Varoquaux, Ganesh Tata, Hleb Levitski, Guillaume Lemaitre, Haoying Zhang, Harmanan Kohli, Ily, ioangatop, IsaacTrost, Isaac Virshup, Iwona Zdzieblo, Jakub Kaczmarzyk, James McDermott, Jarrod Millman, JB Mountford, Jérémie du Boisberranger, Jérôme Dockès, Jiawei Zhang, Joel Nothman, John Cant, John Hopfensperger, Jona Sassenhagen, Jon Nordby, Julien Jerphanion, Kennedy Waweru, kevin moore, Kian Eliasi, Kishan Ved, Konstantinos Pitas, Koustav Ghosh, Kushan Sharma, ldwy4, Linus, Lohit SundaramahaLingam, Loic Esteve, Lorenz, Louis Fouquet, Lucy Liu, Luis Silvestrin, Lukáš Folwarczný, Lukas Geiger, Malte Londschien, Marcus Fraaß, Marek Hanuš, Maren Westermann, Mark Elliot, Martin Larralde, Mateusz Sokół, mathurinm, mecopur, Meekail Zain, Michael Higgins, Miki Watanabe, Milton Gomez, MN193, Mohammed Hamdy, Mohit Joshi, mrastgoo, Naman Dhingra, Naoise Holohan, Narendra Singh dangi, Noa Malem-Shinitski, Nolan, Nurseit Kamchyev, Oleksii Kachaiev, Olivier Grisel, Omar Salman, partev, Peter Hull, Peter Steinbach, Pierre de Fréminville, Pooja Subramaniam, Puneeth K, qmarcou, Quentin Barthélemy, Rahil Parikh, Rahul Mahajan, Raj Pulapakura, Raphael, Ricardo Peres, Riccardo Cappuzzo, Roman Lutz, Salim Dohri, Samuel O. Ronsin, Sandip Dutta, Sayed Qaiser Ali, scaja, scikit-learn-bot, Sebastian Berg, Shreesha Kumar Bhat, Shubhal Gupta, Søren Fuglede Jørgensen, Stefanie Senger, Tamara, Tanjina Afroj, THARAK HEGDE, thebabush, Thomas J. Fan, Thomas Roehr, Tialo, Tim Head, tongyu, Venkatachalam N, Vijeth Moudgalya, Vincent M, Vivek Reddy P, Vladimir Fokow, Xiao Yuan, Xuefeng Xu, Yang Tao, Yao Xiao, Yuchen Zhou, Yuusuke Hiramatsu