Version 1.3
scikit-learn Docs · نسخهٔ 5e9184e53cd3 · BSD-3-Clause
===========
Version 1.3
For a short description of the main highlights of the release, please refer to sphx_glr_auto_examples_release_highlights_plot_release_highlights_1_3_0.py.
Version 1.3.2
October 2023
Changelog
sklearn.datasets .......................
- |Fix| All dataset fetchers now accept
data_homeas any object that implements
the os.PathLike interface, for instance, pathlib.Path. 27468 by Yao Xiao <Charlie-XIAO>.
sklearn.decomposition ............................
- |Fix| Fixes a bug in
decomposition.KernelPCAby forcing the output of
the internal preprocessing.KernelCenterer to be a default array. When the arpack solver is used, it expects an array with a dtype attribute. 27583 by Guillaume Lemaitre <glemaitre>.
sklearn.metrics ......................
- |Fix| Fixes a bug for metrics using
zero_division=np.nan
(e.g. ~metrics.precision_score) within a parallel loop (e.g. ~model_selection.cross_val_score) where the singleton for np.nan will be different in the sub-processes. 27573 by Guillaume Lemaitre <glemaitre>.
sklearn.tree ...................
- |Fix| Do not leak data via non-initialized memory in decision tree pickle files and make
the generation of those files deterministic. 27580 by Loïc Estève <lesteve>.
Version 1.3.1
September 2023
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.
- |Fix| Ridge models with
solver='sparse_cg'may have slightly different
results with scipy>=1.12, because of an underlying change in the scipy solver (see scipy#18488 <https://github.com/scipy/scipy/pull/18488>_ for more details) 26814 by Loïc Estève <lesteve>
Changes impacting all modules
- |Fix| The
set_outputAPI correctly works with list input.27044by
Thomas Fan_.
Changelog
sklearn.calibration ..........................
- |Fix|
calibration.CalibratedClassifierCVcan now handle models that
produce large prediction scores. Before it was numerically unstable. 26913 by Omar Salman <OmarManzoor>.
sklearn.cluster ......................
- |Fix|
cluster.BisectingKMeanscould crash when predicting on data
with a different scale than the data used to fit the model. 27167 by Olivier Grisel_.
- |Fix|
cluster.BisectingKMeansnow works with data that has a single feature.
27243 by Jérémie du Boisberranger <jeremiedbb>.
sklearn.cross_decomposition ..................................
- |Fix|
cross_decomposition.PLSRegressionnow automatically ravels the output
of predict if fitted with one dimensional y. 26602 by Yao Xiao <Charlie-XIAO>.
sklearn.ensemble .......................
- |Fix| Fix a bug in
ensemble.AdaBoostClassifierwithalgorithm="SAMME"
where the decision function of each weak learner should be symmetric (i.e. the sum of the scores should sum to zero for a sample). 26521 by Guillaume Lemaitre <glemaitre>.
sklearn.feature_selection ................................
- |Fix|
feature_selection.mutual_info_regressionnow correctly computes the
result when X is of integer dtype. 26748 by Yao Xiao <Charlie-XIAO>.
sklearn.impute .....................
- |Fix|
impute.KNNImputernow correctly adds a missing indicator column in
`transform when add_indicator is set to True and missing values are observed during fit. 26600 by Shreesha Kumar Bhat <Shreesha3112>`.
sklearn.metrics ......................
- |Fix| Scorers used with
metrics.get_scorerhandle properly
multilabel-indicator matrix. 27002 by Guillaume Lemaitre <glemaitre>.
sklearn.mixture ......................
- |Fix| The initialization of
mixture.GaussianMixturefrom user-provided
precisions_init for covariance_type of full or tied was not correct, and has been fixed. 26416 by Yang Tao <mchikyt3>.
sklearn.neighbors ........................
- |Fix|
neighbors.KNeighborsClassifier.predictno longer raises an
exception for pandas.DataFrames input. 26772 by Jérémie du Boisberranger <jeremiedbb>.
- |Fix| Reintroduce
sklearn.neighbors.BallTree.valid_metricsand
sklearn.neighbors.KDTree.valid_metrics as public class attributes. 26754 by Julien Jerphanion <jjerphan>.
- |Fix|
sklearn.model_selection.HalvingRandomSearchCVno longer raises
when the input to the param_distributions parameter is a list of dicts. 26893 by Stefanie Senger <StefanieSenger>.
- |Fix| Neighbors based estimators now correctly work when
metric="minkowski"and the
metric parameter p is in the range 0 < p < 1, regardless of the dtype of X. 26760 by Shreesha Kumar Bhat <Shreesha3112>.
sklearn.preprocessing ............................
- |Fix|
preprocessing.LabelEncodercorrectly acceptsyas a keyword
argument. 26940 by Thomas Fan_.
- |Fix|
preprocessing.OneHotEncodershows a more informative error message
when sparse_output=True and the output is configured to be pandas. 26931 by Thomas Fan_.
sklearn.tree ...................
- |Fix|
tree.plot_treenow acceptsclass_names=Trueas documented.
26903 by Thomas Roehr <2maz>
- |Fix| The
feature_namesparameter oftree.plot_treenow accepts any kind of
array-like instead of just a list. 27292 by Rahil Parikh <rprkh>.
Version 1.3.0
June 2023
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.
- |Enhancement|
multiclass.OutputCodeClassifier.predictnow uses a more
efficient pairwise distance reduction. As a consequence, the tie-breaking strategy is different and thus the predicted labels may be different. 25196 by Guillaume Lemaitre <glemaitre>.
- |Enhancement| The
fit_transformmethod ofdecomposition.DictionaryLearning
is more efficient but may produce different results as in previous versions when transform_algorithm is not the same as fit_algorithm and the number of iterations is small. 24871 by Omar Salman <OmarManzoor>.
- |Enhancement| The
sample_weightparameter now will be used in centroids
initialization for cluster.KMeans, cluster.BisectingKMeans and cluster.MiniBatchKMeans. This change will break backward compatibility, since numbers generated from same random seeds will be different. 25752 by Hleb Levitski <glevv>, Jérémie du Boisberranger <jeremiedbb>, Guillaume Lemaitre <glemaitre>.
- |Fix| Treat more consistently small values in the
WandHmatrices during the
fit and transform steps of decomposition.NMF and decomposition.MiniBatchNMF which can produce different results than previous versions. 25438 by Yotam Avidar-Constantini <yotamcons>.
- |Fix|
decomposition.KernelPCAmay produce different results through
inverse_transform if gamma is None. Now it will be chosen correctly as 1/n_features of the data that it is fitted on, while previously it might be incorrectly chosen as 1/n_features of the data passed to inverse_transform. A new attribute gamma_ is provided for revealing the actual value of gamma used each time the kernel is called. 26337 by Yao Xiao <Charlie-XIAO>.
Changed displays
- |Enhancement|
model_selection.LearningCurveDisplaydisplays both the
train and test curves by default. You can set score_type="test" to keep the past behaviour. 25120 by Guillaume Lemaitre <glemaitre>.
- |Fix|
model_selection.ValidationCurveDisplaynow accepts passing a
list to the param_range parameter. 27311 by Arturo Amor <ArturoAmorQ>.
Changes impacting all modules
- |Enhancement| The
get_feature_names_outmethod of the following classes now
raises a NotFittedError if the instance is not fitted. This ensures the error is consistent in all estimators with the get_feature_names_out method.
impute.MissingIndicatorfeature_extraction.DictVectorizerfeature_extraction.text.TfidfTransformerfeature_selection.GenericUnivariateSelectfeature_selection.RFEfeature_selection.RFECVfeature_selection.SelectFdrfeature_selection.SelectFprfeature_selection.SelectFromModelfeature_selection.SelectFwefeature_selection.SelectKBestfeature_selection.SelectPercentilefeature_selection.SequentialFeatureSelectorfeature_selection.VarianceThresholdkernel_approximation.AdditiveChi2Samplerimpute.IterativeImputerimpute.KNNImputerimpute.SimpleImputerisotonic.IsotonicRegressionpreprocessing.Binarizerpreprocessing.KBinsDiscretizerpreprocessing.MaxAbsScalerpreprocessing.MinMaxScalerpreprocessing.Normalizerpreprocessing.OrdinalEncoderpreprocessing.PowerTransformerpreprocessing.QuantileTransformerpreprocessing.RobustScalerpreprocessing.SplineTransformerpreprocessing.StandardScalerrandom_projection.GaussianRandomProjectionrandom_projection.SparseRandomProjection
The NotFittedError displays an informative message asking to fit the instance with the appropriate arguments.
25294, 25308, 25291, 25367, 25402, by John Pangas <jpangas>, Rahil Parikh <rprkh> , and Alex Buzenet <albuzenet>.
- |Enhancement| Added a multi-threaded Cython routine to the compute squared
Euclidean distances (sometimes followed by a fused reduction operation) for a pair of datasets consisting of a sparse CSR matrix and a dense NumPy.
This can improve the performance of following functions and estimators:
sklearn.metrics.pairwise_distances_argminsklearn.metrics.pairwise_distances_argmin_minsklearn.cluster.AffinityPropagationsklearn.cluster.Birchsklearn.cluster.MeanShiftsklearn.cluster.OPTICSsklearn.cluster.SpectralClusteringsklearn.feature_selection.mutual_info_regressionsklearn.neighbors.KNeighborsClassifiersklearn.neighbors.KNeighborsRegressorsklearn.neighbors.RadiusNeighborsClassifiersklearn.neighbors.RadiusNeighborsRegressorsklearn.neighbors.LocalOutlierFactorsklearn.neighbors.NearestNeighborssklearn.manifold.Isomapsklearn.manifold.LocallyLinearEmbeddingsklearn.manifold.TSNEsklearn.manifold.trustworthinesssklearn.semi_supervised.LabelPropagationsklearn.semi_supervised.LabelSpreading
A typical example of this performance improvement happens when passing a sparse CSR matrix to the predict or transform method of estimators that rely on a dense NumPy representation to store their fitted parameters (or the reverse).
For instance, sklearn.neighbors.NearestNeighbors.kneighbors is now up to 2 times faster for this case on commonly available laptops.
25044 by Julien Jerphanion <jjerphan>.
- |Enhancement| All estimators that internally rely on OpenMP multi-threading
(via Cython) now use a number of threads equal to the number of physical (instead of logical) cores by default. In the past, we observed that using as many threads as logical cores on SMT hosts could sometimes cause severe performance problems depending on the algorithms and the shape of the data. Note that it is still possible to manually adjust the number of threads used by OpenMP as documented in parallelism.
26082 by Jérémie du Boisberranger <jeremiedbb> and Olivier Grisel <ogrisel>.
Experimental / Under Development
- |MajorFeature|
Metadata routing <metadata_routing>'s related base
methods are included in this release. This feature is only available via the enable_metadata_routing feature flag which can be enabled using sklearn.set_config and sklearn.config_context. For now this feature is mostly useful for third party developers to prepare their code base for metadata routing, and we strongly recommend that they also hide it behind the same feature flag, rather than having it enabled by default. 24027 by Adrin Jalali_, Benjamin Bossan <BenjaminBossan>, and Omar Salman <OmarManzoor>.
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 123456 is the *pull request* number, not the issue number.
sklearn .........
- |Feature| Added a new option
skip_parameter_validation, to the function
sklearn.set_config and context manager sklearn.config_context, that allows to skip the validation of the parameters passed to the estimators and public functions. This can be useful to speed up the code but should be used with care because it can lead to unexpected behaviors or raise obscure error messages when setting invalid parameters. 25815 by Jérémie du Boisberranger <jeremiedbb>.
sklearn.base ...................
- |Feature| A
__sklearn_clone__protocol is now available to override the
default behavior of base.clone. 24568 by Thomas Fan_.
- |Fix|
base.TransformerMixinnow currently keeps a namedtuple's class
if transform returns a namedtuple. 26121 by Thomas Fan_.
sklearn.calibration ..........................
- |Fix|
calibration.CalibratedClassifierCVnow does not enforce sample
alignment on fit_params. 25805 by Adrin Jalali_.
sklearn.cluster ......................
- |MajorFeature| Added
cluster.HDBSCAN, a modern hierarchical density-based
clustering algorithm. Similarly to cluster.OPTICS, it can be seen as a generalization of cluster.DBSCAN by allowing for hierarchical instead of flat clustering, however it varies in its approach from cluster.OPTICS. This algorithm is very robust with respect to its hyperparameters' values and can be used on a wide variety of data without much, if any, tuning.
This implementation is an adaptation from the original implementation of HDBSCAN in scikit-learn-contrib/hdbscan <https://github.com/scikit-learn-contrib/hdbscan>_, by Leland McInnes <lmcinnes> et al.
26385 by Meekail Zain <micky774>
- |Enhancement| The
sample_weightparameter now will be used in centroids
initialization for cluster.KMeans, cluster.BisectingKMeans and cluster.MiniBatchKMeans. This change will break backward compatibility, since numbers generated from same random seeds will be different. 25752 by Hleb Levitski <glevv>, Jérémie du Boisberranger <jeremiedbb>, Guillaume Lemaitre <glemaitre>.
- |Fix|
cluster.KMeans,cluster.MiniBatchKMeansand
cluster.k_means now correctly handle the combination of n_init="auto" and init being an array-like, running one initialization in that case. 26657 by Binesh Bannerjee <bnsh>.
- |API| The
sample_weightparameter inpredictfor
cluster.KMeans.predict and cluster.MiniBatchKMeans.predict is now deprecated and will be removed in v1.5. 25251 by Hleb Levitski <glevv>.
- |API| The
Xredargument incluster.FeatureAgglomeration.inverse_transform
is renamed to Xt and will be removed in v1.5. 26503 by Adrin Jalali_.
sklearn.compose ......................
- |Fix|
compose.ColumnTransformerraises an informative error when the individual
transformers of ColumnTransformer output pandas dataframes with indexes that are not consistent with each other and the output is configured to be pandas. 26286 by Thomas Fan_.
- |Fix|
compose.ColumnTransformercorrectly sets the output of the
remainder when set_output is called. 26323 by Thomas Fan_.
sklearn.covariance .........................
- |Fix| Allows
alpha=0incovariance.GraphicalLassoto be
consistent with covariance.graphical_lasso. 26033 by Genesis Valencia <genvalen>.
- |Fix|
covariance.empirical_covariancenow gives an informative
error message when input is not appropriate. 26108 by Quentin Barthélemy <qbarthelemy>.
- |API| Deprecates
cov_initincovariance.graphical_lassoin 1.3 since
the parameter has no effect. It will be removed in 1.5. 26033 by Genesis Valencia <genvalen>.
- |API| Adds
costs_fitted attribute incovariance.GraphicalLassoand
covariance.GraphicalLassoCV. 26033 by Genesis Valencia <genvalen>.
- |API| Adds
covarianceparameter incovariance.GraphicalLasso.
26033 by Genesis Valencia <genvalen>.
- |API| Adds
epsparameter incovariance.GraphicalLasso,
covariance.graphical_lasso, and covariance.GraphicalLassoCV. 26033 by Genesis Valencia <genvalen>.
sklearn.datasets .......................
- |Enhancement| Allows to overwrite the parameters used to open the ARFF file using
the parameter read_csv_kwargs in datasets.fetch_openml when using the pandas parser. 26433 by Guillaume Lemaitre <glemaitre>.
- |Fix|
datasets.fetch_openmlreturns improved data types when
as_frame=True and parser="liac-arff". 26386 by Thomas Fan_.
- |Fix| Following the ARFF specs, only the marker
"?"is now considered as a missing
values when opening ARFF files fetched using datasets.fetch_openml when using the pandas parser. The parameter read_csv_kwargs allows to overwrite this behaviour. 26551 by Guillaume Lemaitre <glemaitre>.
- |Fix|
datasets.fetch_openmlwill consistently usenp.nanas missing marker
with both parsers "pandas" and "liac-arff". 26579 by Guillaume Lemaitre <glemaitre>.
- |API| The
data_transposedargument ofdatasets.make_sparse_coded_signal
is deprecated and will be removed in v1.5. 25784 by Jérémie du Boisberranger.
sklearn.decomposition ............................
- |Efficiency|
decomposition.MiniBatchDictionaryLearningand
decomposition.MiniBatchSparsePCA are now faster for small batch sizes by avoiding duplicate validations. 25490 by Jérémie du Boisberranger <jeremiedbb>.
- |Enhancement|
decomposition.DictionaryLearningnow accepts the parameter
callback for consistency with the function decomposition.dict_learning. 24871 by Omar Salman <OmarManzoor>.
- |Fix| Treat more consistently small values in the
WandHmatrices during the
fit and transform steps of decomposition.NMF and decomposition.MiniBatchNMF which can produce different results than previous versions. 25438 by Yotam Avidar-Constantini <yotamcons>.
- |API| The
Wargument indecomposition.NMF.inverse_transformand
decomposition.MiniBatchNMF.inverse_transform is renamed to Xt and will be removed in v1.5. 26503 by Adrin Jalali_.
sklearn.discriminant_analysis ....................................
- |Enhancement|
discriminant_analysis.LinearDiscriminantAnalysisnow
supports the PyTorch <https://pytorch.org/>__. See array_api for more details. 25956 by Thomas Fan_.
sklearn.ensemble .......................
- |Feature|
ensemble.HistGradientBoostingRegressornow supports
the Gamma deviance loss via loss="gamma". Using the Gamma deviance as loss function comes in handy for modelling skewed distributed, strictly positive valued targets. 22409 by Christian Lorentzen <lorentzenchr>.
- |Feature| Compute a custom out-of-bag score by passing a callable to
ensemble.RandomForestClassifier, ensemble.RandomForestRegressor, ensemble.ExtraTreesClassifier and ensemble.ExtraTreesRegressor. 25177 by Tim Head_.
- |Feature|
ensemble.GradientBoostingClassifiernow exposes
out-of-bag scores via the oob_scores_ or oob_score_ attributes. 24882 by Ashwin Mathur <awinml>.
- |Efficiency|
ensemble.IsolationForestpredict time is now faster
(typically by a factor of 8 or more). Internally, the estimator now precomputes decision path lengths per tree at fit time. It is therefore not possible to load an estimator trained with scikit-learn 1.2 to make it predict with scikit-learn 1.3: retraining with scikit-learn 1.3 is required. 25186 by Felipe Breve Siola <fsiola>.
- |Efficiency|
ensemble.RandomForestClassifierand
ensemble.RandomForestRegressor with warm_start=True now only recomputes out-of-bag scores when there are actually more n_estimators in subsequent fit calls. 26318 by Joshua Choo Yun Keat <choo8>.
- |Enhancement|
ensemble.BaggingClassifierand
ensemble.BaggingRegressor expose the allow_nan tag from the underlying estimator. 25506 by Thomas Fan_.
- |Fix|
ensemble.RandomForestClassifier.fitsetsmax_samples = 1
when max_samples is a float and round(n_samples * max_samples) < 1. 25601 by Jan Fidor <JanFidor>.
- |Fix|
ensemble.IsolationForest.fitno longer warns about missing
feature names when called with contamination not "auto" on a pandas dataframe. 25931 by Yao Xiao <Charlie-XIAO>.
- |Fix|
ensemble.HistGradientBoostingRegressorand
ensemble.HistGradientBoostingClassifier treats negative values for categorical features consistently as missing values, following LightGBM's and pandas' conventions. 25629 by Thomas Fan_.
- |Fix| Fix deprecation of
base_estimatorinensemble.AdaBoostClassifier
and ensemble.AdaBoostRegressor that was introduced in 23819. 26242 by Marko Toplak <markotoplak>.
sklearn.exceptions .........................
- |Feature| Added
exceptions.InconsistentVersionWarningwhich is raised
when a scikit-learn estimator is unpickled with a scikit-learn version that is inconsistent with the scikit-learn version the estimator was pickled with. 25297 by Thomas Fan_.
sklearn.feature_extraction .................................
- |API|
feature_extraction.image.PatchExtractornow follows the
transformer API of scikit-learn. This class is defined as a stateless transformer meaning that it is not required to call fit before calling transform. Parameter validation only happens at fit time. 24230 by Guillaume Lemaitre <glemaitre>.
sklearn.feature_selection ................................
- |Enhancement| All selectors in
sklearn.feature_selectionwill preserve
a DataFrame's dtype when transformed. 25102 by Thomas Fan_.
- |Fix|
feature_selection.SequentialFeatureSelector'scvparameter
now supports generators. 25973 by Yao Xiao <Charlie-XIAO>.
sklearn.impute .....................
- |Enhancement| Added the parameter
fill_valuetoimpute.IterativeImputer.
25232 by Thijs van Weezel <ValueInvestorThijs>.
- |Fix|
impute.IterativeImputernow correctly preserves the Pandas
Index when the set_config(transform_output="pandas"). 26454 by Thomas Fan_.
sklearn.inspection .........................
- |Enhancement| Added support for
sample_weightin
inspection.partial_dependence and inspection.PartialDependenceDisplay.from_estimator. This allows for weighted averaging when aggregating for each value of the grid we are making the inspection on. The option is only available when method is set to brute. 25209 and 26644 by Carlo Lemos <vitaliset>.
- |API|
inspection.partial_dependencereturns autils.Bunchwith
new key: grid_values. The values key is deprecated in favor of grid_values and the values key will be removed in 1.5. 21809 and 25732 by Thomas Fan_.
sklearn.kernel_approximation ...................................
- |Fix|
kernel_approximation.AdditiveChi2Sampleris now stateless.
The sample_interval_ attribute is deprecated and will be removed in 1.5. 25190 by Vincent Maladière <Vincent-Maladiere>.
sklearn.linear_model ...........................
- |Efficiency| Avoid data scaling when
sample_weight=Noneand other
unnecessary data copies and unexpected dense to sparse data conversion in linear_model.LinearRegression. 26207 by Olivier Grisel <ogrisel>.
- |Enhancement|
linear_model.SGDClassifier,
linear_model.SGDRegressor and linear_model.SGDOneClassSVM now preserve dtype for numpy.float32. 25587 by Omar Salman <OmarManzoor>.
- |Enhancement| The
n_iter_attribute has been included in
linear_model.ARDRegression to expose the actual number of iterations required to reach the stopping criterion. 25697 by John Pangas <jpangas>.
- |Fix| Use a more robust criterion to detect convergence of
linear_model.LogisticRegression with penalty="l1" and solver="liblinear" on linearly separable problems. 25214 by Tom Dupre la Tour_.
- |Fix| Fix a crash when calling
fiton
linear_model.LogisticRegression with solver="newton-cholesky" and max_iter=0 which failed to inspect the state of the model prior to the first parameter update. 26653 by Olivier Grisel <ogrisel>.
- |API| Deprecates
n_iterin favor ofmax_iterin
linear_model.BayesianRidge and linear_model.ARDRegression. n_iter will be removed in scikit-learn 1.5. This change makes those estimators consistent with the rest of estimators. 25697 by John Pangas <jpangas>.
sklearn.manifold .......................
- |Fix|
manifold.Isomapnow correctly preserves the Pandas
Index when the set_config(transform_output="pandas"). 26454 by Thomas Fan_.
sklearn.metrics ......................
- |Feature| Adds
zero_division=np.nanto multiple classification metrics:
metrics.precision_score, metrics.recall_score, metrics.f1_score, metrics.fbeta_score, metrics.precision_recall_fscore_support, metrics.classification_report. When zero_division=np.nan and there is a zero division, the metric is undefined and is excluded from averaging. When not used for averages, the value returned is np.nan. 25531 by Marc Torrellas Socastro <marctorsoc>.
- |Feature|
metrics.average_precision_scorenow supports the
multiclass case. 17388 by Geoffrey Bolmier <gbolmier> and 24769 by Ashwin Mathur <awinml>.
- |Efficiency| The computation of the expected mutual information in
metrics.adjusted_mutual_info_score is now faster when the number of unique labels is large and its memory usage is reduced in general. 25713 by Kshitij Mathur <Kshitij68>, Guillaume Lemaitre <glemaitre>, Omar Salman <OmarManzoor> and Jérémie du Boisberranger <jeremiedbb>.
- |Enhancement|
metrics.silhouette_samplesnow accepts a sparse
matrix of pairwise distances between samples, or a feature array. 18723 by Sahil Gupta <sahilgupta2105> and 24677 by Ashwin Mathur <awinml>.
- |Enhancement| A new parameter
drop_intermediatewas added to
metrics.precision_recall_curve, metrics.PrecisionRecallDisplay.from_estimator, metrics.PrecisionRecallDisplay.from_predictions, which drops some suboptimal thresholds to create lighter precision-recall curves. 24668 by dberenbaum.
- |Enhancement|
metrics.RocCurveDisplay.from_estimatorand
metrics.RocCurveDisplay.from_predictions now accept two new keywords, plot_chance_level and chance_level_kw to plot the baseline chance level. This line is exposed in the chance_level_ attribute. 25987 by Yao Xiao <Charlie-XIAO>.
- |Enhancement|
metrics.PrecisionRecallDisplay.from_estimatorand
metrics.PrecisionRecallDisplay.from_predictions now accept two new keywords, plot_chance_level and chance_level_kw to plot the baseline chance level. This line is exposed in the chance_level_ attribute. 26019 by Yao Xiao <Charlie-XIAO>.
- |Fix|
metrics.pairwise.manhattan_distancesnow supports readonly sparse datasets.
25432 by Julien Jerphanion <jjerphan>.
- |Fix| Fixed
metrics.classification_reportso that empty input will return
np.nan. Previously, "macro avg" and weighted avg would return e.g. f1-score=np.nan and f1-score=0.0, being inconsistent. Now, they both return np.nan. 25531 by Marc Torrellas Socastro <marctorsoc>.
- |Fix|
metrics.ndcg_scorenow gives a meaningful error message for input of
length 1. 25672 by Lene Preuss <lene> and Wei-Chun Chu <wcchu>.
- |Fix|
metrics.log_lossraises a warning if the values of the parameter
y_pred are not normalized, instead of actually normalizing them in the metric. Starting from 1.5 this will raise an error. 25299 by Omar Salman <OmarManzoor.
- |Fix| In
metrics.roc_curve, use the threshold valuenp.infinstead of
arbitrary max(y_score) + 1. This threshold is associated with the ROC curve point tpr=0 and fpr=0. 26194 by Guillaume Lemaitre <glemaitre>.
- |Fix| The
'matching'metric has been removed when using SciPy>=1.9
to be consistent with scipy.spatial.distance which does not support 'matching' anymore. 26264 by Barata T. Onggo <magnusbarata>
- |API| The
epsparameter of themetrics.log_losshas been deprecated and
will be removed in 1.5. 25299 by Omar Salman <OmarManzoor>.
sklearn.gaussian_process ...............................
- |Fix|
gaussian_process.GaussianProcessRegressorhas a new argument
n_targets, which is used to decide the number of outputs when sampling from the prior distributions. 23099 by Zhehao Liu <MaxwellLZH>.
sklearn.mixture ......................
- |Efficiency|
mixture.GaussianMixtureis more efficient now and will bypass
unnecessary initialization if the weights, means, and precisions are given by users. 26021 by Jiawei Zhang <jiawei-zhang-a>.
sklearn.model_selection ..............................
- |MajorFeature| Added the class
model_selection.ValidationCurveDisplay
that allows easy plotting of validation curves obtained by the function model_selection.validation_curve. 25120 by Guillaume Lemaitre <glemaitre>.
- |API| The parameter
log_scalein the methodplotof the class
model_selection.LearningCurveDisplay has been deprecated in 1.3 and will be removed in 1.5. The default scale can be overridden by setting it directly on the ax object and will be set automatically from the spacing of the data points otherwise. 25120 by Guillaume Lemaitre <glemaitre>.
- |Enhancement|
model_selection.cross_validateaccepts a new parameter
return_indices to return the train-test indices of each cv split. 25659 by Guillaume Lemaitre <glemaitre>.
sklearn.multioutput ..........................
- |Fix|
getattronmultioutput.MultiOutputRegressor.partial_fit
and multioutput.MultiOutputClassifier.partial_fit now correctly raise an AttributeError if done before calling fit. 26333 by Adrin Jalali_.
sklearn.naive_bayes ..........................
- |Fix|
naive_bayes.GaussianNBdoes not raise anymore aZeroDivisionError
when the provided sample_weight reduces the problem to a single class in fit. 24140 by Jonathan Ohayon <Johayon> and Chiara Marmo <cmarmo>.
sklearn.neighbors ........................
- |Enhancement| The performance of
neighbors.KNeighborsClassifier.predict
and of neighbors.KNeighborsClassifier.predict_proba has been improved when n_neighbors is large and algorithm="brute" with non Euclidean metrics. 24076 by Meekail Zain <micky774>, Julien Jerphanion <jjerphan>.
- |Fix| Remove support for
KulsinskiDistanceinneighbors.BallTree. This
dissimilarity is not a metric and cannot be supported by the BallTree. 25417 by Guillaume Lemaitre <glemaitre>.
- |API| The support for metrics other than
euclideanandmanhattanand for
callables in neighbors.NearestNeighbors is deprecated and will be removed in version 1.5. 24083 by Valentin Laurent <Valentin-Laurent>.
sklearn.neural_network .............................
- |Fix|
neural_network.MLPRegressorandneural_network.MLPClassifier
reports the right n_iter_ when warm_start=True. It corresponds to the number of iterations performed on the current call to fit instead of the total number of iterations performed since the initialization of the estimator. 25443 by Marvin Krawutschke <Marvvxi>.
sklearn.pipeline .......................
- |Feature|
pipeline.FeatureUnioncan now use indexing notation (e.g.
feature_union["scalar"]) to access transformers by name. 25093 by Thomas Fan_.
- |Feature|
pipeline.FeatureUnioncan now access the
feature_names_in_ attribute if the X value seen during .fit has a columns attribute and all columns are strings. e.g. when X is a pandas.DataFrame 25220 by Ian Thompson <it176131>.
- |Fix|
pipeline.Pipeline.fit_transformnow raises anAttributeError
if the last step of the pipeline does not support fit_transform. 26325 by Adrin Jalali_.
sklearn.preprocessing ............................
- |MajorFeature| Introduces
preprocessing.TargetEncoderwhich is a
categorical encoding based on target mean conditioned on the value of the category. 25334 by Thomas Fan_.
- |Feature|
preprocessing.OrdinalEncodernow supports grouping
infrequent categories into a single feature. Grouping infrequent categories is enabled by specifying how to select infrequent categories with min_frequency or max_categories. 25677 by Thomas Fan_.
- |Enhancement|
preprocessing.PolynomialFeaturesnow calculates the
number of expanded terms a-priori when dealing with sparse csr matrices in order to optimize the choice of dtype for indices and indptr. It can now output csr matrices with np.int32 indices/indptr components when there are few enough elements, and will automatically use np.int64 for sufficiently large matrices. 20524 by niuk-a <niuk-a> and 23731 by Meekail Zain <micky774>
- |Enhancement| A new parameter
sparse_outputwas added to
preprocessing.SplineTransformer, available as of SciPy 1.8. If sparse_output=True, preprocessing.SplineTransformer returns a sparse CSR matrix. 24145 by Christian Lorentzen <lorentzenchr>.
- |Enhancement| Adds a
feature_name_combinerparameter to
preprocessing.OneHotEncoder. This specifies a custom callable to create feature names to be returned by preprocessing.OneHotEncoder.get_feature_names_out. The callable combines input arguments (input_feature, category) to a string. 22506 by Mario Kostelac <mariokostelac>.
- |Enhancement| Added support for
sample_weightin
preprocessing.KBinsDiscretizer. This allows specifying the parameter sample_weight for each sample to be used while fitting. The option is only available when strategy is set to quantile and kmeans. 24935 by Seladus <seladus>, Guillaume Lemaitre <glemaitre>, and Dea María Léon <deamarialeon>, 25257 by Hleb Levitski <glevv>.
- |Enhancement| Subsampling through the
subsampleparameter can now be used in
preprocessing.KBinsDiscretizer regardless of the strategy used. 26424 by Jérémie du Boisberranger <jeremiedbb>.
- |Fix|
preprocessing.PowerTransformernow correctly preserves the Pandas
Index when the set_config(transform_output="pandas"). 26454 by Thomas Fan_.
- |Fix|
preprocessing.PowerTransformernow correctly raises error when
using method="box-cox" on data with a constant np.nan column. 26400 by Yao Xiao <Charlie-XIAO>.
- |Fix|
preprocessing.PowerTransformerwithmethod="yeo-johnson"now leaves
constant features unchanged instead of transforming with an arbitrary value for the lambdas_ fitted parameter. 26566 by Jérémie du Boisberranger <jeremiedbb>.
- |API| The default value of the
subsampleparameter of
preprocessing.KBinsDiscretizer will change from None to 200_000 in version 1.5 when strategy="kmeans" or strategy="uniform". 26424 by Jérémie du Boisberranger <jeremiedbb>.
sklearn.svm ..................
- |API|
dualparameter now acceptsautooption for
svm.LinearSVC and svm.LinearSVR. 26093 by Hleb Levitski <glevv>.
sklearn.tree ...................
- |MajorFeature|
tree.DecisionTreeRegressorand
tree.DecisionTreeClassifier support missing values when splitter='best' and criterion is gini, entropy, or log_loss, for classification or squared_error, friedman_mse, or poisson for regression. 23595, 26376 by Thomas Fan_.
- |Enhancement| Adds a
class_namesparameter to
tree.export_text. This allows specifying the parameter class_names for each target class in ascending numerical order. 25387 by William M <Akbeeh> and crispinlogan <crispinlogan>.
- |Fix|
tree.export_graphvizandtree.export_textnow accepts
feature_names and class_names as array-like rather than lists. 26289 by Yao Xiao <Charlie-XIAO>
sklearn.utils ....................
- |FIX| Fixes
utils.check_arrayto properly convert pandas
extension arrays. 25813 and 26106 by Thomas Fan_.
- |Fix|
utils.check_arraynow supports pandas DataFrames with
extension arrays and object dtypes by returning an ndarray with object dtype. 25814 by Thomas Fan_.
- |API|
utils.estimator_checks.check_transformers_unfitted_statelesshas been
introduced to ensure stateless transformers don't raise NotFittedError during transform with no prior call to fit or fit_transform. 25190 by Vincent Maladière <Vincent-Maladiere>.
- |API| A
FutureWarningis now raised when instantiating a class which inherits from
a deprecated base class (i.e. decorated by utils.deprecated) and which overrides the __init__ method. 25733 by Brigitta Sipőcz <bsipocz> and Jérémie du Boisberranger <jeremiedbb>.
sklearn.semi_supervised ..............................
- |Enhancement|
semi_supervised.LabelSpreading.fitand
semi_supervised.LabelPropagation.fit now accepts sparse metrics. 19664 by Kaushik Amar Das <cozek>.
Miscellaneous .............
- |Enhancement| Replace obsolete exceptions
EnvironmentError,IOErrorand
WindowsError. 26466 by Dimitri Papadopoulos ORfanos <DimitriPapadopoulos>.
Thanks to everyone who has contributed to the maintenance and improvement of the project since version 1.2, including:
2357juan, Abhishek Singh Kushwah, Adam Handke, Adam Kania, Adam Li, adienes, Admir Demiraj, adoublet, Adrin Jalali, A.H.Mansouri, Ahmedbgh, Ala-Na, Alex Buzenet, AlexL, Ali H. El-Kassas, amay, András Simon, André Pedersen, Andrew Wang, Ankur Singh, annegnx, Ansam Zedan, Anthony22-dev, Artur Hermano, Arturo Amor, as-90, ashah002, Ashish Dutt, Ashwin Mathur, AymericBasset, Azaria Gebremichael, Barata Tripramudya Onggo, Benedek Harsanyi, Benjamin Bossan, Bharat Raghunathan, Binesh Bannerjee, Boris Feld, Brendan Lu, Brevin Kunde, cache-missing, Camille Troillard, Carla J, carlo, Carlo Lemos, c-git, Changyao Chen, Chiara Marmo, Christian Lorentzen, Christian Veenhuis, Christine P. Chai, crispinlogan, Da-Lan, DanGonite57, Dave Berenbaum, davidblnc, david-cortes, Dayne, Dea María Léon, Denis, Dimitri Papadopoulos Orfanos, Dimitris Litsidis, Dmitry Nesterov, Dominic Fox, Dominik Prodinger, Edern, Ekaterina Butyugina, Elabonga Atuo, Emir, farhan khan, Felipe Siola, futurewarning, Gael Varoquaux, genvalen, Hleb Levitski, Guillaume Lemaitre, gunesbayir, Haesun Park, hujiahong726, i-aki-y, Ian Thompson, Ido M, Ily, Irene, Jack McIvor, jakirkham, James Dean, JanFidor, Jarrod Millman, JB Mountford, Jérémie du Boisberranger, Jessicakk0711, Jiawei Zhang, Joey Ortiz, JohnathanPi, John Pangas, Joshua Choo Yun Keat, Joshua Hedlund, JuliaSchoepp, Julien Jerphanion, jygerardy, ka00ri, Kaushik Amar Das, Kento Nozawa, Kian Eliasi, Kilian Kluge, Lene Preuss, Linus, Logan Thomas, Loic Esteve, Louis Fouquet, Lucy Liu, Madhura Jayaratne, Marc Torrellas Socastro, Maren Westermann, Mario Kostelac, Mark Harfouche, Marko Toplak, Marvin Krawutschke, Masanori Kanazu, mathurinm, Matt Haberland, Max Halford, maximeSaur, Maxwell Liu, m. bou, mdarii, Meekail Zain, Mikhail Iljin, murezzda, Nawazish Alam, Nicola Fanelli, Nightwalkx, Nikolay Petrov, Nishu Choudhary, NNLNR, npache, Olivier Grisel, Omar Salman, ouss1508, PAB, Pandata, partev, Peter Piontek, Phil, pnucci, Pooja M, Pooja Subramaniam, precondition, Quentin Barthélemy, Rafal Wojdyla, Raghuveer Bhat, Rahil Parikh, Ralf Gommers, ram vikram singh, Rushil Desai, Sadra Barikbin, SANJAI_3, Sashka Warner, Scott Gigante, Scott Gustafson, searchforpassion, Seoeun Hong, Shady el Gewily, Shiva chauhan, Shogo Hida, Shreesha Kumar Bhat, sonnivs, Sortofamudkip, Stanislav (Stanley) Modrak, Stefanie Senger, Steven Van Vaerenbergh, Tabea Kossen, Théophile Baranger, Thijs van Weezel, Thomas A Caswell, Thomas Germer, Thomas J. Fan, Tim Head, Tim P, Tom Dupré la Tour, tomiock, tspeng, Valentin Laurent, Veghit, VIGNESH D, Vijeth Moudgalya, Vinayak Mehta, Vincent M, Vincent-violet, Vyom Pathak, William M, windiana42, Xiao Yuan, Yao Xiao, Yaroslav Halchenko, Yotam Avidar-Constantini, Yuchen Zhou, Yusuf Raji, zeeshan lone