Version 0.20 (under development)¶
This release packs in a mountain of bug fixes, features and enhancements for the Scikit-learn library, and improvements to the documentation and examples. Thanks to our many contributors!
Highlights¶
We have tried to improve our support for common data-science use-cases including missing values, categorical variables, heterogeneous data, and features/targets with unusual distributions.
Missing values in features, represented by NaNs, are now accepted in
column-wise preprocessing such as scalers. Each feature is fitted disregarding
NaNs, and data containing NaNs can be transformed. The new impute
module provides estimators for learning despite missing data.
ColumnTransformer
handles the case where different features
or columns of a pandas.DataFrame need different preprocessing.
String or pandas Categorical columns can now be encoded with
OneHotEncoder
or
OrdinalEncoder
.
TransformedTargetRegressor
helps when the regression target
needs to be transformed to be modeled. PowerTransformer
and KBinsDiscretizer
join
QuantileTransformer
as non-linear transformations.
Beyond this, we have added sample_weight support to several estimators
(including KMeans
, BayesianRidge
and
KernelDensity
) and improved stopping criteria in others
(including MLPRegressor
,
GradientBoostingRegressor
and
SGDRegressor
).
This release is also the first to be accompanied by a Glossary of Common Terms and API Elements developed by Joel Nothman. The glossary is a reference resource to help users and contributors become familiar with the terminology and conventions used in Scikit-learn.
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.
decomposition.IncrementalPCA
in Python 2 (bug fix)isotonic.IsotonicRegression
(bug fix)linear_model.ARDRegression
(bug fix)linear_model.OrthogonalMatchingPursuit
(bug fix)metrics.roc_auc_score
(bug fix)metrics.roc_curve
(bug fix)neural_network.MLPRegressor
(bug fix)neural_network.MLPClassifier
(bug fix)neural_network.BaseMultilayerPerceptron
(bug fix)linear_model.SGDClassifier
(bug fix)linear_model.SGDRegressor
(bug fix)linear_model.PassiveAggressiveClassifier
(bug fix)linear_model.PassiveAggressiveRegressor
(bug fix)linear_model.Perceptron
(bug fix)ensemble.gradient_boosting.GradientBoostingClassifier
(bug fix affecting feature importances)- The v0.19.0 release notes failed to mention a backwards incompatibility with
model_selection.StratifiedKFold
whenshuffle=True
due to #7823.
Details are listed in the changelog below.
(While we are trying to better inform users by providing this information, we cannot assure that this list is complete.)
Changelog¶
Support for Python 3.3 has been officially dropped.
New features¶
Classifiers and regressors
ensemble.GradientBoostingClassifier
andensemble.GradientBoostingRegressor
now support early stopping vian_iter_no_change
,validation_fraction
andtol
. #7071 by Raghav RVdummy.DummyRegressor
now has areturn_std
option in itspredict
method. The returned standard deviations will be zeros.- Added
multioutput.RegressorChain
for multi-target regression. #9257 by Kumar Ashutosh. - Added
naive_bayes.ComplementNB
, which implements the Complement Naive Bayes classifier described in Rennie et al. (2003). #8190 by Michael A. Alcorn. ensemble.BaggingRegressor
andensemble.BaggingClassifier
can now be fit with missing/non-finite values in X and/or multi-output Y to support wrapping pipelines that perform their own imputation. #9707 by Jimmy Wan.
Preprocessing
- Expanded
preprocessing.OneHotEncoder
to allow to encode categorical string features as a numeric array using a one-hot (or dummy) encoding scheme, and addedpreprocessing.OrdinalEncoder
to convert to ordinal integers. Those two classes now handle encoding of all feature types (also handles string-valued features) and derives the categories based on the unique values in the features instead of the maximum value in the features. #9151 and #10521 by Vighnesh Birodkar and Joris Van den Bossche. - Added
preprocessing.KBinsDiscretizer
for turning continuous features into categorical or one-hot encoded features. #7668, #9647, #10195, #10192, #11272 and #11467. by Henry Lin, Hanmin Qin and Tom Dupre la Tour. - Added
compose.ColumnTransformer
, which allows to apply different transformers to different columns of arrays or pandas DataFrames. #9012 by Andreas Müller and Joris Van den Bossche, and #11315 by Thomas Fan. - Added
preprocessing.PowerTransformer
, which implements the Box-Cox power transformation, allowing users to map data from any distribution to a Gaussian distribution. This is useful as a variance-stabilizing transformation in situations where normality and homoscedasticity are desirable. #10210 by Eric Chang and Maniteja Nandana. - Added the
compose.TransformedTargetRegressor
which transforms the target y before fitting a regression model. The predictions are mapped back to the original space via an inverse transform. #9041 by Andreas Müller and Guillaume Lemaitre. - Added
impute.ChainedImputer
, which is a strategy for imputing missing values by modeling each feature with missing values as a function of other features in a round-robin fashion. #8478 by Sergey Feldman. linear_model.SGDClassifier
,linear_model.SGDRegressor
,linear_model.PassiveAggressiveClassifier
,linear_model.PassiveAggressiveRegressor
andlinear_model.Perceptron
now exposeearly_stopping
,validation_fraction
andn_iter_no_change
parameters, to stop optimization monitoring the score on a validation set. A new learning rate"adaptive"
strategy divides the learning rate by 5 each timen_iter_no_change
consecutive epochs fail to improve the model. #9043 by Tom Dupre la Tour.
Model evaluation
- Added the
metrics.davies_bouldin_score
metric for unsupervised evaluation of clustering models. #10827 by Luis Osa. - Added the
metrics.balanced_accuracy_score
metric and a corresponding'balanced_accuracy'
scorer for binary classification. #8066 by @xyguo and Aman Dalmia.
Decomposition, manifold learning and clustering
cluster.AgglomerativeClustering
now supports Single Linkage clustering vialinkage='single'
. #9372 by Leland McInnes and Steve Astels.cluster.KMeans
andcluster.MiniBatchKMeans
now support sample weights via new parametersample_weight
infit
function. #10933 by Johannes Hansen.dict_learning
functions and models now support positivity constraints. This applies to the dictionary and sparse code. #6374 by John Kirkham.
Metrics
- Partial AUC is available via
max_fpr
parameter inmetrics.roc_auc_score
. #3273 by Alexander Niederbühl. - Added
output_dict
parameter inmetrics.classification_report
to return classification statistics as dictionary. #11160 by Dan Barkhorn.
Misc
- A new configuration parameter,
working_memory
was added to control memory consumption limits in chunked operations, such as the newmetrics.pairwise_distances_chunked
. See Limiting Working Memory. #10280 by Joel Nothman and Aman Dalmia. - An environment variable to use the site joblib instead of the vendored
one was added (Environment variables). The main API of joblib is now
exposed in
sklearn.utils.joblib
. #11166 by Gael Varoquaux, Joel Nothman and Olivier Grisel.
Enhancements¶
Classifiers and regressors
- In
gaussian_process.GaussianProcessRegressor
, methodpredict
is faster when usingreturn_std=True
in particular more when called several times in a row. #9234 by andrewww and Minghui Liu. - Add named_estimators_ parameter in
ensemble.VotingClassifier
to access fitted estimators. #9157 by Herilalaina Rakotoarison. - Add var_smoothing parameter in
naive_bayes.GaussianNB
to give a precise control over variances calculation. #9681 by Dmitry Mottl. - Add n_iter_no_change parameter in
neural_network.BaseMultilayerPerceptron
,neural_network.MLPRegressor
, andneural_network.MLPClassifier
to give control over maximum number of epochs to not meettol
improvement. #9456 by Nicholas Nadeau. - A parameter
check_inverse
was added topreprocessing.FunctionTransformer
to ensure thatfunc
andinverse_func
are the inverse of each other. #9399 by Guillaume Lemaitre. - Add sample_weight parameter to the fit method of
linear_model.BayesianRidge
for weighted linear regression. #10111 by Peter St. John. dummy.DummyClassifier
anddummy.DummyRegressor
now only require X to be an object with finite length or shape. #9832 by Vrishank Bhardwaj.- Add sample_weight parameter to the fit method of
neighbors.KernelDensity
to enables weighting in kernel density estimation. #4394 by Samuel O. Ronsin. neighbors.RadiusNeighborsRegressor
andneighbors.RadiusNeighborsClassifier
are now parallelized according ton_jobs
regardless ofalgorithm
. #8003 by Joël Billaud.- Memory usage improvement for
_class_means
and_class_cov
indiscriminant_analysis
. #10898 by Nanxin Chen.` manifold.t_sne.trustworthiness
accepts metrics other than Euclidean. #9775 by William de Vazelhes.Nearest neighbors
query methods are now more memory efficient whenalgorithm='brute'
. #11136 by Joel Nothman and Aman Dalmia.
Cluster
cluster.KMeans
,cluster.MiniBatchKMeans
andcluster.k_means
passed withalgorithm='full'
now enforces row-major ordering, improving runtime. #10471 by Gaurav Dhingra.cluster.DBSCAN
now is parallelized according ton_jobs
regardless ofalgorithm
. #8003 by Joël Billaud.
Datasets
- In
datasets.make_blobs
, one can now pass a list to the n_samples parameter to indicate the number of samples to generate per cluster. #8617 by Maskani Filali Mohamed and Konstantinos Katrioplas.
Preprocessing
preprocessing.PolynomialFeatures
now supports sparse input. #10452 by Aman Dalmia and Joel Nothman.- Enable the call to
get_feature_names
in unfittedfeature_extraction.text.CountVectorizer
initialized with a vocabulary. #10908 by Mohamed Maskani. - The
transform
method ofsklearn.preprocessing.MultiLabelBinarizer
now ignores any unknown classes. A warning is raised stating the unknown classes classes found which are ignored. #10913 by Rodrigo Agundez. - NaN values are ignored and handled in the following preprocessing methods:
preprocessing.MaxAbsScaler
,preprocessing.MinMaxScaler
,preprocessing.RobustScaler
,preprocessing.StandardScaler
,preprocessing.PowerTransformer
,preprocessing.QuantileTransformer
classes andpreprocessing.maxabs_scale
,preprocessing.minmax_scale
,preprocessing.robust_scale
,preprocessing.scale
,preprocessing.power_transform
,preprocessing.quantile_transform
functions respectively addressed in issues #11011, #11005, #11308, #11206, #11306, and #10437. By Lucija Gregov and Guillaume Lemaitre. preprocessing.RobustScaler
andpreprocessing.robust_scale
can be fitted using sparse matrices. #11308 by Guillaume Lemaitre.
Model evaluation and meta-estimators
- A scorer based on
metrics.brier_score_loss
is also available. #9521 by Hanmin Qin. - The default of
iid
parameter ofmodel_selection.GridSearchCV
andmodel_selection.RandomizedSearchCV
will change fromTrue
toFalse
in version 0.22 to correspond to the standard definition of cross-validation, and the parameter will be removed in version 0.24 altogether. This parameter is of greatest practical significance where the sizes of different test sets in cross-validation were very unequal, i.e. in group-based CV strategies. #9085 by Laurent Direr and Andreas Müller. - The
predict
method ofpipeline.Pipeline
now passes keyword arguments on to the pipeline’s last estimator, enabling the use of parameters such asreturn_std
in a pipeline with caution. #9304 by Breno Freitas. - Add return_estimator parameter in
model_selection.cross_validate
to return estimators fitted on each split. #9686 by Aurélien Bellet. - New
refit_time_
attribute will be stored inmodel_selection.GridSearchCV
andmodel_selection.RandomizedSearchCV
ifrefit
is set toTrue
. This will allow measuring the complete time it takes to perform hyperparameter optimization and refitting the best model on the whole dataset. #11310 by Matthias Feurer.
Decomposition and manifold learning
- Speed improvements for both ‘exact’ and ‘barnes_hut’ methods in
manifold.TSNE
. #10593 and #10610 by Tom Dupre la Tour. - Support sparse input in
manifold.Isomap.fit
. #8554 by Leland McInnes.
Metrics
metrics.roc_auc_score
now supports binaryy_true
other than{0, 1}
or{-1, 1}
. #9828 by Hanmin Qin.metrics.label_ranking_average_precision_score
now supports vectorsample_weight
. #10845 by Jose Perez-Parras Toledano.- Add
dense_output
parameter tometrics.pairwise.linear_kernel
. When False and both inputs are sparse, will return a sparse matrix. #10999 by Taylor G Smith. metrics.cluster.silhouette_score
andmetrics.cluster.silhouette_samples
are more memory efficient and run faster. This avoids some reported freezes and MemoryErrors. #11135 by Joel Nothman.
Linear, kernelized and related models
- Deprecate
random_state
parameter insvm.OneClassSVM
as the underlying implementation is not random. #9497 by Albert Thomas.
Decomposition, manifold learning and clustering
- Deprecate
precomputed
parameter in functionmanifold.t_sne.trustworthiness
. Instead, the new parametermetric
should be used with any compatible metric including ‘precomputed’, in which case the input matrixX
should be a matrix of pairwise distances or squared distances. #9775 by William de Vazelhes.
Utils
- Avoid copying the data in
utils.check_array
when the input data is a memmap (andcopy=False
). #10663 by Arthur Mensch and Loïc Estève.
Miscellaneous
- Add
filename
attribute to datasets that have a CSV file. #9101 by alex-33 and Maskani Filali Mohamed.
Bug fixes¶
Classifiers and regressors
- Fixed a bug in
isotonic.IsotonicRegression
which incorrectly combined weights when fitting a model to data involving points with identical X values. #9432 by Dallas Card - Fixed a bug in
neural_network.BaseMultilayerPerceptron
,neural_network.MLPRegressor
, andneural_network.MLPClassifier
with newn_iter_no_change
parameter now at 10 from previously hardcoded 2. #9456 by Nicholas Nadeau. - Fixed a bug in
neural_network.MLPRegressor
where fitting quit unexpectedly early due to local minima or fluctuations. #9456 by Nicholas Nadeau - Fixed a bug in
naive_bayes.GaussianNB
which incorrectly raised error for prior list which summed to 1. #10005 by Gaurav Dhingra. - Fixed a bug in
linear_model.LogisticRegression
where when using the parametermulti_class='multinomial'
, thepredict_proba
method was returning incorrect probabilities in the case of binary outcomes. #9939 by Roger Westover. - Fixed a bug in
linear_model.LogisticRegressionCV
where thescore
method always computes accuracy, not the metric given by thescoring
parameter. #10998 by Thomas Fan. - Fixed a bug in
linear_model.OrthogonalMatchingPursuit
that was broken when settingnormalize=False
. #10071 by Alexandre Gramfort. - Fixed a bug in
linear_model.ARDRegression
which caused incorrectly updated estimates for the standard deviation and the coefficients. #10153 by Jörg Döpfert. - Fixed a bug when fitting
ensemble.GradientBoostingClassifier
orensemble.GradientBoostingRegressor
withwarm_start=True
which previously raised a segmentation fault due to a non-conversion of CSC matrix into CSR format expected bydecision_function
. Similarly, Fortran-ordered arrays are converted to C-ordered arrays in the dense case. #9991 by Guillaume Lemaitre. - Fixed a bug in
neighbors.NearestNeighbors
where fitting a NearestNeighbors model fails when a) the distance metric used is a callable and b) the input to the NearestNeighbors model is sparse. #9579 by Thomas Kober. - Fixed a bug in
linear_model.RidgeClassifierCV
where the parameterstore_cv_values
was not implemented though it was documented incv_values
as a way to set up the storage of cross-validation values for different alphas. #10297 by Mabel Villalba-Jiménez. - Fixed a bug in
naive_bayes.MultinomialNB
which did not accept vector valued pseudocounts (alpha). #10346 by Tobias Madsen - Fixed a bug in
svm.SVC
where when the argumentkernel
is unicode in Python2, thepredict_proba
method was raising an unexpected TypeError given dense inputs. #10412 by Jiongyan Zhang. - Fixed a bug in
tree.BaseDecisionTree
with splitter=”best” where split threshold could become infinite when values in X were near infinite. #10536 by Jonathan Ohayon. - Fixed a bug in
linear_model.ElasticNet
which caused the input to be overridden when using parametercopy_X=True
andcheck_input=False
. #10581 by Yacine Mazari. - Fixed a bug in
sklearn.linear_model.Lasso
where the coefficient had wrong shape whenfit_intercept=False
. #10687 by Martin Hahn. - Fixed a bug in
sklearn.linear_model.LogisticRegression
where the multi_class=’multinomial’ with binary output with warm_start = True #10836 by Aishwarya Srinivasan. - Fixed a bug in
linear_model.RidgeCV
where using integeralphas
raised an error. #10393 by Mabel Villalba-Jiménez. - Fixed condition triggering gap computation in
linear_model.Lasso
andlinear_model.ElasticNet
when working with sparse matrices. #10992 by Alexandre Gramfort. - Fixed a bug in
linear_model.SGDClassifier
,linear_model.SGDRegressor
,linear_model.PassiveAggressiveClassifier
,linear_model.PassiveAggressiveRegressor
andlinear_model.Perceptron
, where the stopping criterion was stopping the algorithm before convergence. A parameter n_iter_no_change was added and set by default to 5. Previous behavior is equivalent to setting the parameter to 1. #9043 by Tom Dupre la Tour. - Fixed a bug where liblinear and libsvm-based estimators would segfault if passed a scipy.sparse matrix with 64-bit indices. They now raise a ValueError. #11327 by Karan Dhingra and Joel Nothman.
- Fixed a bug in
ensemble.gradient_boosting.GradientBoostingRegressor
andensemble.gradient_boosting.GradientBoostingClassifier
to have feature importances summed and then normalized, rather than normalizing on a per-tree basis. The previous behavior over-weighted the Gini importance of features that appear in later stages. This issue only affected feature importances. #11176 by Gil Forsyth.
Decomposition, manifold learning and clustering
- Fix for uninformative error in
decomposition.IncrementalPCA
: now an error is raised if the number of components is larger than the chosen batch size. Then_components=None
case was adapted accordingly. #6452. By Wally Gauze. - Fixed a bug where the
partial_fit
method ofdecomposition.IncrementalPCA
used integer division instead of float division on Python 2 versions. #9492 by James Bourbeau. - Fixed a bug where the
fit
method ofcluster.AffinityPropagation
stored cluster centers as 3d array instead of 2d array in case of non-convergence. For the same class, fixed undefined and arbitrary behavior in case of training data where all samples had equal similarity. #9612. By Jonatan Samoocha. - In
decomposition.PCA
selecting a n_components parameter greater than the number of samples now raises an error. Similarly, then_components=None
case now selects the minimum of n_samples and n_features. #8484. By Wally Gauze. - Fixed a bug in
datasets.fetch_kddcup99
, where data were not properly shuffled. #9731 by Nicolas Goix. - Fixed a bug in
decomposition.PCA
where users will get unexpected error with large datasets whenn_components='mle'
on Python 3 versions. #9886 by Hanmin Qin. - Fixed a bug when setting parameters on meta-estimator, involving both a wrapped estimator and its parameter. #9999 by Marcus Voss and Joel Nothman.
k_means
now gives a warning, if the number of distinct clusters found is smaller thann_clusters
. This may occur when the number of distinct points in the data set is actually smaller than the number of cluster one is looking for. #10059 by Christian Braune.- Fixed a bug in
datasets.make_circles
, where no odd number of data points could be generated. #10037 by Christian Braune. - Fixed a bug in
cluster.spectral_clustering
where the normalization of the spectrum was using a division instead of a multiplication. #8129 by Jan Margeta, Guillaume Lemaitre, and Devansh D.. - Fixed a bug in
mixture.BaseMixture
where the reported n_iter_ was missing an iteration. It affectedmixture.GaussianMixture
andmixture.BayesianGaussianMixture
. #10740 by Erich Schubert and Guillaume Lemaitre. - Fixed a bug in
decomposition.SparseCoder
when running OMP sparse coding in parallel using readonly memory mapped datastructures. #5956 by Vighnesh Birodkar and Olivier Grisel. - Fixed a bug in
cluster.k_means_elkan
where the returned iteration was 1 less than the correct value. Also added the missing n_iter_ attribute in the docstring ofcluster.KMeans
. #11353 by Jeremie du Boisberranger.
Metrics
- Fixed a bug in
metrics.precision_recall_fscore_support
when truncated range(n_labels) is passed as value for labels. #10377 by Gaurav Dhingra. - Fixed a bug due to floating point error in
metrics.roc_auc_score
with non-integer sample weights. #9786 by Hanmin Qin. - Fixed a bug where
metrics.roc_curve
sometimes starts on y-axis instead of (0, 0), which is inconsistent with the document and other implementations. Note that this will not influence the result frommetrics.roc_auc_score
#10093 by alexryndin and Hanmin Qin. - Fixed a bug to avoid integer overflow. Casted product to 64 bits integer in
metrics.mutual_info_score
. #9772 by Kumar Ashutosh. - Fixed a bug in
metrics.fowlkes_mallows_score
to avoid integer overflow. Casted return value of contingency_matrix to int64 and computed product of square roots rather than square root of product. #9515 by Alan Liddell and Manh Dao.
Neighbors
- Fixed a bug so
predict
inneighbors.RadiusNeighborsRegressor
can handle empty neighbor set when using non uniform weights. Also raises a new warning when no neighbors are found for samples. #9655 by Andreas Bjerre-Nielsen.
Feature Extraction
- Fixed a bug in
feature_extraction.image.extract_patches_2d
which would throw an exception ifmax_patches
was greater than or equal to the number of all possible patches rather than simply returning the number of possible patches. #10100 by Varun Agrawal - Fixed a bug in
feature_extraction.text.CountVectorizer
,feature_extraction.text.TfidfVectorizer
,feature_extraction.text.HashingVectorizer
to support 64 bit sparse array indexing necessary to process large datasets with more than 2·10⁹ tokens (words or n-grams). #9147 by Claes-Fredrik Mannby and Roman Yurchak. - Fixed bug in
feature_extraction.text.TFIDFVectorizer
which was ignoring the parameterdtype
. In addition,feature_extraction.text.TFIDFTransformer
will preservedtype
for floating and raise a warning ifdtype
requested is integer. #10441 by Mayur Kulkarni and Guillaume Lemaitre.
Utils
utils.check_array
yield aFutureWarning
indicating that arrays of bytes/strings will be interpreted as decimal numbers beginning in version 0.22. #10229 by Ryan Lee
Preprocessing
- Fixed bugs in
preprocessing.LabelEncoder
which would sometimes throw errors whentransform
orinverse_transform
was called with empty arrays. #10458 by Mayur Kulkarni. - Fix ValueError in
preprocessing.LabelEncoder
when usinginverse_transform
on unseen labels. #9816 by Charlie Newey. - Fix bug in
preprocessing.OneHotEncoder
which discarded thedtype
when returning a sparse matrix output. #11042 by Daniel Morales. - Fix
fit
andpartial_fit
inpreprocessing.StandardScaler
in the rare case when with_mean=False and with_std=False which was crashing by callingfit
more than once and giving inconsistent results formean_
whether the input was a sparse or a dense matrix.mean_
will be set toNone
with both sparse and dense inputs.n_samples_seen_
will be also reported for both input types. #11235 by Guillaume Lemaitre.
Feature selection
- Fixed computation of
n_features_to_compute
for edge case with tied CV scores infeature_selection.RFECV
. #9222 by Nick Hoh <nickypie>.
Model evaluation and meta-estimators
- Add improved error message in
model_selection.cross_val_score
when multiple metrics are passed inscoring
keyword. #11006 by Ming Li.
Datasets
- Fixed a bug in
datasets.load_boston
which had a wrong data point. #10801 by Takeshi Yoshizawa. - Fixed a bug in
datasets.load_iris
which had two wrong data points. #11082 by Sadhana Srinivasan and Hanmin Qin.
API changes summary¶
Linear, kernelized and related models
- Deprecate
random_state
parameter insvm.OneClassSVM
as the underlying implementation is not random. #9497 by Albert Thomas. - Deprecate
positive=True
option inlinear_model.Lars
as the underlying implementation is broken. Uselinear_model.Lasso
instead. #9837 by Alexandre Gramfort. n_iter_
may vary from previous releases inlinear_model.LogisticRegression
withsolver='lbfgs'
andlinear_model.HuberRegressor
. For Scipy <= 1.0.0, the optimizer could perform more than the requested maximum number of iterations. Now both estimators will report at mostmax_iter
iterations even if more were performed. #10723 by Joel Nothman.- The default value of
gamma
parameter ofsvm.SVC
,NuSVC
,SVR
,NuSVR
,OneClassSVM
will change from'auto'
to'scale'
in version 0.22 to account better for unscaled features. #8361 by Gaurav Dhingra and Ting Neo. - Added convergence warning to
svm.LinearSVC
andlinear_model.LogisticRegression
whenverbose
is set to 0. #10881 by Alexandre Sevin.
Preprocessing
- Deprecate
n_values
andcategorical_features
parameters andactive_features_
,feature_indices_
andn_values_
attributes ofpreprocessing.OneHotEncoder
. Then_values
parameter can be replaced with the newcategories
parameter, and the attributes with the newcategories_
attribute. Selecting the categorical features with thecategorical_features
parameter is now better supported using thecompose.ColumnTransformer
. #10521 by Joris Van den Bossche.
Decomposition, manifold learning and clustering
- Deprecate
precomputed
parameter in functionmanifold.t_sne.trustworthiness
. Instead, the new parametermetric
should be used with any compatible metric including ‘precomputed’, in which case the input matrixX
should be a matrix of pairwise distances or squared distances. #9775 by William de Vazelhes. - Added function
fit_predict
tomixture.GaussianMixture
andmixture.GaussianMixture
, which is essentially equivalent to callingfit
andpredict
. #10336 by Shu Haoran and Andrew Peng.
Metrics
- Deprecate
reorder
parameter inmetrics.auc
as it’s no longer required formetrics.roc_auc_score
. Moreover usingreorder=True
can hide bugs due to floating point error in the input. #9851 by Hanmin Qin. - The
batch_size
parameter tometrics.pairwise_distances_argmin_min
andmetrics.pairwise_distances_argmin
is deprecated to be removed in v0.22. It no longer has any effect, as batch size is determined by globalworking_memory
config. See Limiting Working Memory. #10280 by Joel Nothman and Aman Dalmia.
Cluster
- Deprecate
pooling_func
unused parameter incluster.AgglomerativeClustering
. #9875 by Kumar Ashutosh.
Imputer
- Deprecate
preprocessing.Imputer
and move the corresponding module toimpute.SimpleImputer
. #9726 by Kumar Ashutosh. - The
axis
parameter that was inpreprocessing.Imputer
is no longer present inimpute.SimpleImputer
. The behavior is equivalent toaxis=0
(impute along columns). Row-wise imputation can be performed with FunctionTransformer (e.g.,FunctionTransformer(lambda X: SimpleImputer().fit_transform(X.T).T)
). #10829 by Guillaume Lemaitre and Gilberto Olimpio. - The
impute.SimpleImputer
has a new strategy,'constant'
, to complete missing values with a fixed one, given by thefill_value
parameter. This strategy supports numeric and non-numeric data, and so does the'most_frequent'
strategy now. #11211 by Jeremie du Boisberranger. - The NaN marker for the missing values has been changed between the
preprocessing.Imputer
and theimpute.SimpleImputer
.missing_values='NaN'
should now bemissing_values=np.nan
. #11211 by Jeremie du Boisberranger.
Outlier Detection models
- More consistent outlier detection API:
Add a
score_samples
method insvm.OneClassSVM
,ensemble.IsolationForest
,neighbors.LocalOutlierFactor
,covariance.EllipticEnvelope
. It allows to access raw score functions from original papers. A newoffset_
parameter allows to linkscore_samples
anddecision_function
methods. Thecontamination
parameter ofensemble.IsolationForest
andneighbors.LocalOutlierFactor
decision_function
methods is used to define thisoffset_
such that outliers (resp. inliers) have negative (resp. positive)decision_function
values. By default,contamination
is kept unchanged to 0.1 for a deprecation period. In 0.22, it will be set to “auto”, thus using method-specific score offsets. Incovariance.EllipticEnvelope
decision_function
method, theraw_values
parameter is deprecated as the shifted Mahalanobis distance will be always returned in 0.22. #9015 by Nicolas Goix.
Covariance
- The
covariance.graph_lasso
,covariance.GraphLasso
andcovariance.GraphLassoCV
have been renamed tocovariance.graphical_lasso
,covariance.GraphicalLasso
andcovariance.GraphicalLassoCV
respectively and will be removed in version 0.22. #9993 by Artiem Krinitsyn
Misc
- Changed warning type from
UserWarning
toexceptions.ConvergenceWarning
for failing convergence inlinear_model.logistic_regression_path
,linear_model.RANSACRegressor
,linear_model.ridge_regression
,gaussian_process.GaussianProcessRegressor
,gaussian_process.GaussianProcessClassifier
,decomposition.fastica
,cross_decomposition.PLSCanonical
,cluster.AffinityPropagation
, andcluster.Birch
. ##10306 by Jonathan Siebert. - Changed ValueError exception raised in
model_selection.ParameterSampler
to a UserWarning for case where the class is instantiated with a greater value ofn_iter
than the total space of parameters in the parameter grid.n_iter
now acts as an upper bound on iterations. ##10982 by Juliet Lawton - Invalid input for
model_selection.ParameterGrid
now raises TypeError. #10928 by Solutus Immensus utils.check_array
andutils.check_X_y
now haveaccept_large_sparse
to control whether scipy.sparse matrices with 64-bit indices should be rejected. #11327 by Karan Dhingra and Joel Nothman.
Preprocessing
- In
preprocessing.FunctionTransformer
, the default ofvalidate
will be fromTrue
toFalse
in 0.22. #10655 by Guillaume Lemaitre.
Changes to estimator checks¶
These changes mostly affect library developers.
- Allow tests in
utils.estimator_checks.check_estimator
to test functions that accept pairwise data. #9701 by Kyle Johnson - Allow
check_estimator
to check that there is no private settings apart from parameters during estimator initialization. #9378 by Herilalaina Rakotoarison - Add
check_methods_subset_invariance
tocheck_estimator
, which checks that estimator methods are invariant if applied to a data subset. #10420 by Jonathan Ohayon - Add tests in
utils.estimator_checks.check_estimator
to check that an estimator can handle read-only memmap input data. #10663 by Arthur Mensch and Loïc Estève. check_sample_weights_pandas_series
now uses 8 rather than 6 samples to accommodate for the default number of clusters incluster.KMeans
. #10933 by Johannes Hansen.