Skip to content

Latest commit

 

History

History
521 lines (407 loc) · 23 KB

v0.21.rst

File metadata and controls

521 lines (407 loc) · 23 KB

sklearn

Version 0.21.0

In development

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.

  • discriminant_analysis.LinearDiscriminantAnalysis for multiclass classification.
  • discriminant_analysis.LinearDiscriminantAnalysis with 'eigen' solver.
  • linear_model.BayesianRidge
  • Decision trees and derived ensembles when both max_depth and max_leaf_nodes are set.
  • linear_model.LogisticRegression and linear_model.LogisticRegressionCV with 'saga' solver.
  • ensemble.GradientBoostingClassifier for multiclass classification.
  • svm.SVC.decision_function and multiclass.OneVsOneClassifier.decision_function.

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.4 and below has been officially dropped.

sklearn.base

  • The R2 score used when calling score on a regressor will use multioutput='uniform_average' from version 0.23 to keep consistent with metrics.r2_score. This will influence the score method of all the multioutput regressors (except for multioutput.MultiOutputRegressor). 13157 by Hanmin Qin <qinhanmin2014>.

sklearn.calibration

  • Added support to bin the data passed into calibration.calibration_curve by quantiles instead of uniformly between 0 and 1. 13086 by Scott Cole <srcole>.

sklearn.cluster

  • A new clustering algorithm: cluster.OPTICS: an algoritm related to cluster.DBSCAN, that has hyperparameters easier to set and that scales better, by Shane <espg>, Adrin Jalali <adrinjalali>, and Erich Schubert <kno10>.

sklearn.datasets

  • Added support for 64-bit group IDs and pointers in SVMLight files datasets.svmlight_format 10727 by Bryan K Woods <bryan-woods>.
  • datasets.load_sample_images returns images with a deterministic order. 13250 by Thomas Fan <thomasjpfan>.

sklearn.decomposition

  • decomposition.KernelPCA now has deterministic output (resolved sign ambiguity in eigenvalue decomposition of the kernel matrix). 13241 by Aurélien Bellet <bellet>.
  • Fixed a bug in decomposition.NMF where init = 'nndsvd', init = 'nndsvda', and init = 'nndsvdar' are allowed when n_components < n_features instead of n_components <= min(n_samples, n_features). 11650 by Hossein Pourbozorg <hossein-pourbozorg> and Zijie (ZJ) Poh <zjpoh>.
  • The default value of the init argument in decomposition.non_negative_factorization will change from random to None in version 0.23 to make it consistent with decomposition.NMF. A FutureWarning is raised when the default value is used. 12988 by Zijie (ZJ) Poh <zjpoh>.

sklearn.discriminant_analysis

  • discriminant_analysis.LinearDiscriminantAnalysis now preserves float32 and float64 dtypes. 8769 and 11000 by Thibault Sejourne <thibsej>
  • A ChangedBehaviourWarning is now raised when discriminant_analysis.LinearDiscriminantAnalysis is given as parameter n_components > min(n_features, n_classes - 1), and n_components is changed to min(n_features, n_classes - 1) if so. Previously the change was made, but silently. 11526 by William de Vazelhes<wdevazelhes>.
  • Fixed a bug in discriminant_analysis.LinearDiscriminantAnalysis where the predicted probabilities would be incorrectly computed in the multiclass case. 6848, by Agamemnon Krasoulis <agamemnonc> and Guillaume Lemaitre <glemaitre>.
  • Fixed a bug in discriminant_analysis.LinearDiscriminantAnalysis where the predicted probabilities would be incorrectly computed with eigen solver. 11727, by Agamemnon Krasoulis <agamemnonc>.

sklearn.dummy

  • Fixed a bug in dummy.DummyClassifier where the predict_proba method was returning int32 array instead of float64 for the stratified strategy. 13266 by Christos Aridas<chkoar>.

sklearn.ensemble

  • Make ensemble.IsolationForest prefer threads over processes when running with n_jobs > 1 as the underlying decision tree fit calls do release the GIL. This changes reduces memory usage and communication overhead. 12543 by Isaac Storch <istorch> and Olivier Grisel.
  • Minimized the validation of X in ensemble.AdaBoostClassifier and ensemble.AdaBoostRegressor 13174 by Christos Aridas <chkoar>.
  • Fixed a bug in ensemble.GradientBoostingClassifier and ensemble.GradientBoostingRegressor, which didn't support scikit-learn estimators as the initial estimator. Also added support of initial estimator which does not support sample weights. 12436 by Jérémie du Boisberranger <jeremiedbb> and 12983 by Nicolas Hug<NicolasHug>.
  • Fixed the output of the average path length computed in ensemble.IsolationForest when the input is either 0, 1 or 2. 13251 by Albert Thomas <albertcthomas> and joshuakennethjones <joshuakennethjones>.
  • Make ensemble.IsolationForest more memory efficient by avoiding keeping in memory each tree prediction. 13260 by Nicolas Goix.
  • Fixed a bug in ensemble.GradientBoostingClassifier where the gradients would be incorrectly computed in multiclass classification problems. 12715 by Nicolas Hug<NicolasHug>.
  • Fixed a bug in ensemble.GradientBoostingClassifier where the default initial prediction of a multiclass classifier would predict the classes priors instead of the log of the priors. 12983 by Nicolas Hug<NicolasHug>.
  • Fixed a bug in ensemble where the predict method would error for multiclass multioutput forests models if any targets were strings. 12834 by Elizabeth Sander <elsander>.
  • Fixed a bug in ensemble.gradient_boosting.LossFunction and ensemble.gradient_boosting.LeastSquaresError where the default value of learning_rate in update_terminal_regions is not consistent with the document and the caller functions. 6463 by movelikeriver <movelikeriver>.

sklearn.externals

  • Deprecated externals.six since we have dropped support for Python 2.7. 12916 by Hanmin Qin <qinhanmin2014>.

sklearn.impute

  • Added impute.IterativeImputer, 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 and 12177 by Sergey Feldman <sergeyf> Ben Lawson <benlawson>.
  • In impute.MissingIndicator avoid implicit densification by raising an exception if input is sparse add missing_values property is set to 0. 13240 by Bartosz Telenczuk <btel>.

sklearn.isotonic

  • Allow different dtypes (such as float32) in isotonic.IsotonicRegression 8769 by Vlad Niculae <vene>

sklearn.linear_model

  • Fixed a performance issue of saga and sag solvers when called in a joblib.Parallel setting with n_jobs > 1 and backend="threading", causing them to perform worse than in the sequential case. 13389 by Pierre Glaser <pierreglaser>.
  • linear_model.LogisticRegression and linear_model.LogisticRegressionCV now support Elastic-Net penalty, with the 'saga' solver. 11646 by Nicolas Hug <NicolasHug>.
  • Added linear_model.lars_path_gram, which is linear_model.lars_path in the sufficient stats mode, allowing users to compute linear_model.lars_path without providing X and y. 11699 by Kuai Yu <yukuairoy>.
  • linear_model.make_dataset now preserves float32 and float64 dtypes. 8769 and 11000 by Nelle Varoquaux <NelleV>, Arthur Imbert <Henley13>, Guillaume Lemaitre <glemaitre>, and Joan Massich <massich>
  • linear_model.LogisticRegression now supports an unregularized objective by setting penalty to 'none'. This is equivalent to setting C=np.inf with l2 regularization. Not supported by the liblinear solver. 12860 by Nicolas Hug <NicolasHug>.
  • sparse_cg solver in linear_model.ridge.Ridge now supports fitting the intercept (i.e. fit_intercept=True) when inputs are sparse. 13336 by Bartosz Telenczuk <btel>.
  • Fixed a bug in linear_model.LogisticRegression and linear_model.LogisticRegressionCV with 'saga' solver, where the weights would not be correctly updated in some cases. 11646 by Tom Dupre la Tour.
  • Fixed the posterior mean, posterior covariance and returned regularization parameters in linear_model.BayesianRidge. The posterior mean and the posterior covariance were not the ones computed with the last update of the regularization parameters and the returned regularization parameters were not the final ones. Also fixed the formula of the log marginal likelihood used to compute the score when compute_score=True. 12174 by Albert Thomas <albertcthomas>.
  • Fixed a bug in linear_model.LassoLarsIC, where user input copy_X=False at instance creation would be overridden by default parameter value copy_X=True in fit. 12972 by Lucio Fernandez-Arjona <luk-f-a>
  • Fixed a bug in linear_model.LinearRegression that was not returning the same coeffecients and intercepts with fit_intercept=True in sparse and dense case. 13279 by Alexandre Gramfort
  • Fixed a bug in linear_model.HuberRegressor that was broken when X was of dtype bool. 13328 by Alexandre Gramfort.
  • The use of linear_model.lars_path with X=None while passing Gram is deprecated in version 0.21 and will be removed in version 0.23. Use linear_model.lars_path_gram instead. 11699 by Kuai Yu <yukuairoy>.
  • linear_model.logistic_regression_path is deprecated in version 0.21 and will be removed in version 0.23. 12821 by Nicolas Hug <NicolasHug>.

sklearn.manifold

  • Make manifold.tsne.trustworthiness use an inverted index instead of an np.where lookup to find the rank of neighbors in the input space. This improves efficiency in particular when computed with lots of neighbors and/or small datasets. 9907 by William de Vazelhes <wdevazelhes>.

sklearn.metrics

  • Added the metrics.max_error metric and a corresponding 'max_error' scorer for single output regression. 12232 by Krishna Sangeeth <whiletruelearn>.
  • Add metrics.multilabel_confusion_matrix, which calculates a confusion matrix with true positive, false positive, false negative and true negative counts for each class. This facilitates the calculation of set-wise metrics such as recall, specificity, fall out and miss rate. 11179 by Shangwu Yao <ShangwuYao> and Joel Nothman.
  • metrics.jaccard_score has been added to calculate the Jaccard coefficient as an evaluation metric for binary, multilabel and multiclass tasks, with an interface analogous to metrics.f1_score. 13151 by Gaurav Dhingra <gxyd> and Joel Nothman.
  • Faster metrics.pairwise.pairwise_distances with n_jobs > 1 by using a thread-based backend, instead of process-based backends. 8216 by Pierre Glaser <pierreglaser> and Romuald Menuet <zanospi>
  • The pairwise manhattan distances with sparse input now uses the BLAS shipped with scipy instead of the bundled BLAS. 12732 by Jérémie du Boisberranger <jeremiedbb>
  • Use label accuracy instead of micro-average on metrics.classification_report to avoid confusion. micro-average is only shown for multi-label or multi-class with a subset of classes because it is otherwise identical to accuracy. 12334 by Emmanuel Arias <eamanu@eamanu.com>, Joel Nothman and Andreas Müller
  • The metric metrics.r2_score is degenerate with a single sample and now it returns NaN and raises exceptions.UndefinedMetricWarning. 12855 by Pawel Sendyk <psendyk>.
  • The parameter labels in metrics.hamming_loss is deprecated in version 0.21 and will be removed in version 0.23. 10580 by Reshama Shaikh <reshamas> and Sandra Mitrovic <SandraMNE>.
  • metrics.jaccard_similarity_score is deprecated in favour of the more consistent metrics.jaccard_score. The former behavior for binary and multiclass targets is broken. 13151 by Joel Nothman.

sklearn.mixture

  • Fixed a bug in mixture.BaseMixture and therefore on estimators based on it, i.e. mixture.GaussianMixture and mixture.BayesianGaussianMixture, where fit_predict and fit.predict were not equivalent. 13142 by Jérémie du Boisberranger <jeremiedbb>.

sklearn.model_selection

  • Classes ~model_selection.GridSearchCV and ~model_selection.RandomizedSearchCV now allow for refit=callable to add flexibility in identifying the best estimator. An example for this interface has been added. 11354 by Wenhao Zhang <wenhaoz@ucla.edu>, Joel Nothman and Adrin Jalali <adrinjalali>.
  • Classes ~model_selection.GridSearchCV, ~model_selection.RandomizedSearchCV, and methods ~model_selection.cross_val_score, ~model_selection.cross_val_predict, ~model_selection.cross_validate, now print train scores when return_train_scores is True and verbose > 2. For ~model_selection.learning_curve, and ~model_selection.validation_curve only the latter is required. 12613 and 12669 by Marc Torrellas <marctorrellas>.
  • Fixed a bug where model_selection.StratifiedKFold shuffles each class's samples with the same random_state, making shuffle=True ineffective. 13124 by Hanmin Qin <qinhanmin2014>.
  • Fixed an issue in ~model_selection.cross_val_predict where method="predict_proba" returned always 0.0 when one of the classes was excluded in a cross-validation fold. 13366 by Guillaume Fournier <gfournier>

sklearn.multiclass

  • Fixed an issue in multiclass.OneVsOneClassifier.decision_function where the decision_function value of a given sample was different depending on whether the decision_function was evaluated on the sample alone or on a batch containing this same sample due to the scaling used in decision_function. 10440 by Jonathan Ohayon <Johayon>.

sklearn.neighbors

  • A metric learning algorithm: neighbors.NeighborhoodComponentsAnalysis, which implements the Neighborhood Components Analysis algorithm described in Goldberger et al. (2005). 10058 by William de Vazelhes <wdevazelhes> and John Chiotellis <johny-c>.
  • Methods in neighbors.NearestNeighbors : ~neighbors.NearestNeighbors.kneighbors, ~neighbors.NearestNeighbors.radius_neighbors, ~neighbors.NearestNeighbors.kneighbors_graph, ~neighbors.NearestNeighbors.radius_neighbors_graph now raise NotFittedError, rather than AttributeError, when called before fit 12279 by Krishna Sangeeth <whiletruelearn>.

sklearn.neural_network

  • Fixed a bug in neural_network.MLPClassifier and neural_network.MLPRegressor where the option shuffle=False was being ignored. 12582 by Sam Waterbury <samwaterbury>.

sklearn.pipeline

  • pipeline.Pipeline can now use indexing notation (e.g. my_pipeline[0:-1]) to extract a subsequence of steps as another Pipeline instance. A Pipeline can also be indexed directly to extract a particular step (e.g. my_pipeline['svc']), rather than accessing named_steps. 2568 by Joel Nothman.
  • pipeline.Pipeline now supports using 'passthrough' as a transformer. 11144 by Thomas Fan <thomasjpfan>.
  • pipeline.Pipeline implements __len__ and therefore len(pipeline) returns the number of steps in the pipeline. 13439 by Lakshya KD <LakshKD>.

sklearn.preprocessing

  • OneHotEncoder now supports dropping one feature per category with a new drop parameter. 12908 by Drew Johnston <drewmjohnston>.
  • Make preprocessing.MultiLabelBinarizer to cache class mappings instead of calculating it every time on the fly. 12116 by Ekaterina Krivich <kiote> and Joel Nothman.
  • preprocessing.PolynomialFeatures now supports compressed sparse row (CSR) matrices as input for degrees 2 and 3. This is typically much faster than the dense case as it scales with matrix density and expansion degree (on the order of density^degree), and is much, much faster than the compressed sparse column (CSC) case. 12197 by Andrew Nystrom <awnystrom>.
  • Speed improvement in preprocessing.PolynomialFeatures, in the dense case. Also added a new parameter order which controls output order for further speed performances. 12251 by Tom Dupre la Tour.
  • Fixed the calculation overflow when using a float16 dtype with preprocessing.StandardScaler. 13007 by Raffaello Baluyot <baluyotraf>
  • Fixed a bug in preprocessing.QuantileTransformer and preprocessing.quantile_transform to force n_quantiles to be at most equal to n_samples. Values of n_quantiles larger than n_samples were either useless or resulting in a wrong approximation of the cumulative distribution function estimator. 13333 by Albert Thomas <albertcthomas>.

sklearn.svm

  • Fixed an issue in svm.SVC.decision_function when decision_function_shape='ovr'. The decision_function value of a given sample was different depending on whether the decision_function was evaluated on the sample alone or on a batch containing this same sample due to the scaling used in decision_function. 10440 by Jonathan Ohayon <Johayon>.

sklearn.tree

  • Decision Trees can now be plotted with matplotlib using tree.plot_tree without relying on the dot library, removing a hard-to-install dependency. 8508 by Andreas Müller.
  • Decision Trees can now be exported in a human readable textual format using tree.export.export_text. 6261 by Giuseppe Vettigli <JustGlowing>.
  • get_n_leaves() and get_depth() have been added to tree.BaseDecisionTree and consequently all estimators based on it, including tree.DecisionTreeClassifier, tree.DecisionTreeRegressor, tree.ExtraTreeClassifier, and tree.ExtraTreeRegressor. 12300 by Adrin Jalali <adrinjalali>.
  • Fixed an issue with tree.BaseDecisionTree and consequently all estimators based on it, including tree.DecisionTreeClassifier, tree.DecisionTreeRegressor, tree.ExtraTreeClassifier, and tree.ExtraTreeRegressor, where they used to exceed the given max_depth by 1 while expanding the tree if max_leaf_nodes and max_depth were both specified by the user. Please note that this also affects all ensemble methods using decision trees. 12344 by Adrin Jalali <adrinjalali>.

Multiple modules

  • The __repr__() method of all estimators (used when calling print(estimator)) has been entirely re-written, building on Python's pretty printing standard library. All parameters are printed by default, but this can be altered with the print_changed_only option in sklearn.set_config. 11705 by Nicolas Hug <NicolasHug>.
  • Memory copies are avoided when casting arrays to a different dtype in multiple estimators. 11973 by Roman Yurchak <rth>.

Changes to estimator checks

These changes mostly affect library developers.

  • Add check_fit_idempotent to ~utils.estimator_checks.check_estimator, which checks that when fit is called twice with the same data, the ouput of predict, predict_proba, transform, and decision_function does not change. 12328 by Nicolas Hug <NicolasHug>