Question: meanshift and MeanShift don't have the same API I'm trying to make call (related to ) but has a parameter and uses the default, so I cannot preserve backward compatibility without adding to . Should I just do that?

<sphx_glr_auto_examples_cluster_plot_mean_shift.py>`.      """    if bandwidth is None:        bandwidth = estimate_bandwidth(X, n_jobs=n_jobs)    elif bandwidth <= 0:        raise ValueError("bandwidth needs to be greater than zero or None,"                         " got %f" % bandwidth)    if seeds is None:        if bin_seeding:            seeds = get_bin_seeds(X, bandwidth, min_bin_freq)        else:            seeds = X    n_samples, n_features = X.shape    center_intensity_dict = {}    # We use n_jobs=1 because this will be used in nested calls under    # parallel calls to _mean_shift_single_seed so there is no need for    # for further parallelism.    nbrs = NearestNeighbors(radius=bandwidth, n_jobs=1).fit(X)    # execute iterations on all seeds in parallel    all_res = Parallel(n_jobs=n_jobs)(        delayed(_mean_shift_single_seed)        (seed, X, nbrs, max_iter) for seed in seeds)    # copy results in a dictionary    for i in range(len(seeds)):        if all_res[i] is not None:            center_intensity_dict[all_res[i][0]] = all_res[i][1]    if not center_intensity_dict:        # nothing near seeds        raise ValueError("No point was within bandwidth=%f of any seed."                         " Try a different seeding strategy \                         or increase the bandwidth."                         % bandwidth)    # POST PROCESSING: remove near duplicate points    # If the distance between two kernels is less than the bandwidth,    # then we have to remove one because it is a duplicate. Remove the    # one with fewer points.    sorted_by_intensity = sorted(center_intensity_dict.items(),                                 key=lambda tup: (tup[1], tup[0]),                                 reverse=True)    sorted_centers = np.array([tup[0] for tup in sorted_by_intensity])    unique = np.ones(len(sorted_centers), dtype=np.bool)    nbrs = NearestNeighbors(radius=bandwidth,                            n_jobs=n_jobs).fit(sorted_centers)    for i, center in enumerate(sorted_centers):        if unique[i]:            neighbor_idxs = nbrs.radius_neighbors([center],                                                  return_distance=False)[0]            unique[neighbor_idxs] = 0            unique[i] = 1  # leave the current point as unique    cluster_centers = sorted_centers[unique]    # ASSIGN LABELS: a point belongs to the cluster that it is closest to    nbrs = NearestNeighbors(n_neighbors=1, n_jobs=n_jobs).fit(cluster_centers)    labels = np.zeros(n_samples, dtype=np.int)    distances, idxs = nbrs.kneighbors(X)    if cluster_all:        labels = idxs.flatten()    else:        labels.fill(-1)        bool_selector = distances.flatten() <= bandwidth        labels[bool_selector] = idxs.flatten()[bool_selector]    return cluster_centers, labels    model = MeanShift(bandwidth=bandwidth, seeds=seeds,                      min_bin_freq=min_bin_freq,                      bin_seeding=bin_seeding,                      cluster_all=cluster_all, n_jobs=n_jobs,                      max_iter=max_iter).fit(X)    return model.cluster_centers_, model.labels_   def get_bin_seeds(X, bin_size, min_bin_freq=1):


Question: meanshift and MeanShift don't have the same API I'm trying to make call (related to ) but has a parameter and uses the default, so I cannot preserve backward compatibility without adding to . Should I just do that?

``-1`` means using all processors. See :term:`Glossary <n_jobs>`         for more details. <ins>    max_iter : int, default=300        Maximum number of iterations, per seed point before the clustering        operation terminates (for that seed point), if has not converged yet.        .. versionadded:: 0.22</ins>     Attributes     ----------     cluster_centers_ : array, [n_clusters, n_features]


Question: meanshift and MeanShift don't have the same API I'm trying to make call (related to ) but has a parameter and uses the default, so I cannot preserve backward compatibility without adding to . Should I just do that?

labels_ :         Labels of each point. <ins>    n_iter_ : int        Maximum number of iterations performed on each seed.        .. versionadded:: 0.22</ins>     Examples     --------     >>> from sklearn.cluster import MeanShift


Question: meanshift and MeanShift don't have the same API I'm trying to make call (related to ) but has a parameter and uses the default, so I cannot preserve backward compatibility without adding to . Should I just do that?

"""     def __init__(self, bandwidth=None, seeds=None, bin_seeding=False,                 min_bin_freq=1, cluster_all=True, n_jobs=None):                 min_bin_freq=1, cluster_all=True, n_jobs=None, max_iter=300):         self.bandwidth = bandwidth         self.seeds = seeds         self.bin_seeding = bin_seeding         self.cluster_all = cluster_all         self.min_bin_freq = min_bin_freq         self.n_jobs = n_jobs        self.max_iter = max_iter      def fit(self, X, y=None):         """Perform clustering.


Question: meanshift and MeanShift don't have the same API I'm trying to make call (related to ) but has a parameter and uses the default, so I cannot preserve backward compatibility without adding to . Should I just do that?

"""         X = check_array(X)        self.cluster_centers_, self.labels_ = \            mean_shift(X, bandwidth=self.bandwidth, seeds=self.seeds,                       min_bin_freq=self.min_bin_freq,                       bin_seeding=self.bin_seeding,                       cluster_all=self.cluster_all, n_jobs=self.n_jobs)        bandwidth = self.bandwidth        if bandwidth is None:            bandwidth = estimate_bandwidth(X, n_jobs=self.n_jobs)        elif bandwidth <= 0:            raise ValueError("bandwidth needs to be greater than zero or None,"                             " got %f" % bandwidth)        seeds = self.seeds        if seeds is None:            if self.bin_seeding:                seeds = get_bin_seeds(X, bandwidth, self.min_bin_freq)            else:                seeds = X        n_samples, n_features = X.shape        center_intensity_dict = {}        # We use n_jobs=1 because this will be used in nested calls under        # parallel calls to _mean_shift_single_seed so there is no need for        # for further parallelism.        nbrs = NearestNeighbors(radius=bandwidth, n_jobs=1).fit(X)        # execute iterations on all seeds in parallel        all_res = Parallel(n_jobs=self.n_jobs)(            delayed(_mean_shift_single_seed)            (seed, X, nbrs, self.max_iter) for seed in seeds)        # copy results in a dictionary        for i in range(len(seeds)):            if all_res[i][1]:  # i.e. len(points_within) > 0                center_intensity_dict[all_res[i][0]] = all_res[i][1]        self.n_iter_ = max([x[2] for x in all_res])        if not center_intensity_dict:            # nothing near seeds            raise ValueError("No point was within bandwidth=%f of any seed."                             " Try a different seeding strategy \                             or increase the bandwidth."                             % bandwidth)        # POST PROCESSING: remove near duplicate points        # If the distance between two kernels is less than the bandwidth,        # then we have to remove one because it is a duplicate. Remove the        # one with fewer points.        sorted_by_intensity = sorted(center_intensity_dict.items(),                                     key=lambda tup: (tup[1], tup[0]),                                     reverse=True)        sorted_centers = np.array([tup[0] for tup in sorted_by_intensity])        unique = np.ones(len(sorted_centers), dtype=np.bool)        nbrs = NearestNeighbors(radius=bandwidth,                                n_jobs=self.n_jobs).fit(sorted_centers)        for i, center in enumerate(sorted_centers):            if unique[i]:                neighbor_idxs = nbrs.radius_neighbors([center],                                                      return_distance=False)[0]                unique[neighbor_idxs] = 0                unique[i] = 1  # leave the current point as unique        cluster_centers = sorted_centers[unique]        # ASSIGN LABELS: a point belongs to the cluster that it is closest to        nbrs = NearestNeighbors(n_neighbors=1,                                n_jobs=self.n_jobs).fit(cluster_centers)        labels = np.zeros(n_samples, dtype=np.int)        distances, idxs = nbrs.kneighbors(X)        if self.cluster_all:            labels = idxs.flatten()        else:            labels.fill(-1)            bool_selector = distances.flatten() <= bandwidth            labels[bool_selector] = idxs.flatten()[bool_selector]        self.cluster_centers_, self.labels_ = cluster_centers, labels         return self      def predict(self, X):


Question: Stacking: add an option to use the original dataset when training finalestimator I think it will be readonable to add an option to use the original dataset when training finalestimator. This seems reasonable and has proved to be useful in some Kaggle competitions. Reference: implementation from mlxtend usefeaturesinsecondary : bool (default: False) If True, the meta-classifier will be trained both on the predictions of the original classifiers and the original dataset. If False, the meta-classifier will be trained only on the predictions of the original classifiers.

import numpy as np from joblib import Parallel, delayed<ins>import scipy.sparse as sparse</ins>  from ..base import clone from ..base import ClassifierMixin, RegressorMixin, TransformerMixin


Question: Stacking: add an option to use the original dataset when training finalestimator I think it will be readonable to add an option to use the original dataset when training finalestimator. This seems reasonable and has proved to be useful in some Kaggle competitions. Reference: implementation from mlxtend usefeaturesinsecondary : bool (default: False) If True, the meta-classifier will be trained both on the predictions of the original classifiers and the original dataset. If False, the meta-classifier will be trained only on the predictions of the original classifiers.

@abstractmethod     def __init__(self, estimators, final_estimator=None, cv=None,                 stack_method='auto', n_jobs=None, verbose=0):                 stack_method='auto', n_jobs=None, verbose=0,                 passthrough=False):         super().__init__(estimators=estimators)         self.final_estimator = final_estimator         self.cv = cv         self.stack_method = stack_method         self.n_jobs = n_jobs         self.verbose = verbose        self.passthrough = passthrough      def _clone_final_estimator(self, default):         if self.final_estimator is not None:


Question: Stacking: add an option to use the original dataset when training finalestimator I think it will be readonable to add an option to use the original dataset when training finalestimator. This seems reasonable and has proved to be useful in some Kaggle competitions. Reference: implementation from mlxtend usefeaturesinsecondary : bool (default: False) If True, the meta-classifier will be trained both on the predictions of the original classifiers and the original dataset. If False, the meta-classifier will be trained only on the predictions of the original classifiers.

else:             self.final_estimator_ = clone(default)     def _concatenate_predictions(self, predictions):        """Concatenate the predictions of each first layer learner.    def _concatenate_predictions(self, X, predictions):        """Concatenate the predictions of each first layer learner and        possibly the input dataset `X`.        If `X` is sparse and `self.passthrough` is False, the output of        `transform` will be dense (the predictions). If `X` is sparse        and `self.passthrough` is True, the output of `transform` will        be sparse.          This helper is in charge of ensuring the preditions are 2D arrays and         it will drop one of the probability column when using probabilities


Question: Stacking: add an option to use the original dataset when training finalestimator I think it will be readonable to add an option to use the original dataset when training finalestimator. This seems reasonable and has proved to be useful in some Kaggle competitions. Reference: implementation from mlxtend usefeaturesinsecondary : bool (default: False) If True, the meta-classifier will be trained both on the predictions of the original classifiers and the original dataset. If False, the meta-classifier will be trained only on the predictions of the original classifiers.

X_meta.append(preds[:, 1:])                 else:                     X_meta.append(preds)        return np.concatenate(X_meta, axis=1)        if self.passthrough:            X_meta.append(X)            if sparse.issparse(X):                return sparse.hstack(X_meta, format=X.format)        return np.hstack(X_meta)      @staticmethod     def _method_name(name, estimator, method):


Question: Stacking: add an option to use the original dataset when training finalestimator I think it will be readonable to add an option to use the original dataset when training finalestimator. This seems reasonable and has proved to be useful in some Kaggle competitions. Reference: implementation from mlxtend usefeaturesinsecondary : bool (default: False) If True, the meta-classifier will be trained both on the predictions of the original classifiers and the original dataset. If False, the meta-classifier will be trained only on the predictions of the original classifiers.

if est != 'drop'         ]         X_meta = self._concatenate_predictions(predictions)        X_meta = self._concatenate_predictions(X, predictions)         if sample_weight is not None:             try:                 self.final_estimator_.fit(


Question: Stacking: add an option to use the original dataset when training finalestimator I think it will be readonable to add an option to use the original dataset when training finalestimator. This seems reasonable and has proved to be useful in some Kaggle competitions. Reference: implementation from mlxtend usefeaturesinsecondary : bool (default: False) If True, the meta-classifier will be trained both on the predictions of the original classifiers and the original dataset. If False, the meta-classifier will be trained only on the predictions of the original classifiers.

for est, meth in zip(self.estimators_, self.stack_method_)             if est != 'drop'         ]        return self._concatenate_predictions(predictions)        return self._concatenate_predictions(X, predictions)      @if_delegate_has_method(delegate='final_estimator_')     def predict(self, X, **predict_params):


Question: Stacking: add an option to use the original dataset when training finalestimator I think it will be readonable to add an option to use the original dataset when training finalestimator. This seems reasonable and has proved to be useful in some Kaggle competitions. Reference: implementation from mlxtend usefeaturesinsecondary : bool (default: False) If True, the meta-classifier will be trained both on the predictions of the original classifiers and the original dataset. If False, the meta-classifier will be trained only on the predictions of the original classifiers.

`None` means 1 unless in a `joblib.parallel_backend` context. -1 means         using all processors. See Glossary for more details. <ins>    passthrough : bool, default=False        When False, only the predictions of estimators will be used as        training data for `final_estimator`. When True, the        `final_estimator` is trained on the predictions as well as the        original training data.</ins>     Attributes     ----------     estimators_ : list of estimators


Question: Stacking: add an option to use the original dataset when training finalestimator I think it will be readonable to add an option to use the original dataset when training finalestimator. This seems reasonable and has proved to be useful in some Kaggle competitions. Reference: implementation from mlxtend usefeaturesinsecondary : bool (default: False) If True, the meta-classifier will be trained both on the predictions of the original classifiers and the original dataset. If False, the meta-classifier will be trained only on the predictions of the original classifiers.

"""     def __init__(self, estimators, final_estimator=None, cv=None,                 stack_method='auto', n_jobs=None, verbose=0):                 stack_method='auto', n_jobs=None, passthrough=False,                 verbose=0):         super().__init__(             estimators=estimators,             final_estimator=final_estimator,             cv=cv,             stack_method=stack_method,             n_jobs=n_jobs,            passthrough=passthrough,             verbose=verbose         )


Question: Stacking: add an option to use the original dataset when training finalestimator I think it will be readonable to add an option to use the original dataset when training finalestimator. This seems reasonable and has proved to be useful in some Kaggle competitions. Reference: implementation from mlxtend usefeaturesinsecondary : bool (default: False) If True, the meta-classifier will be trained both on the predictions of the original classifiers and the original dataset. If False, the meta-classifier will be trained only on the predictions of the original classifiers.

`None` means 1 unless in a `joblib.parallel_backend` context. -1 means         using all processors. See Glossary for more details. <ins>    passthrough : bool, default=False        When False, only the predictions of estimators will be used as        training data for `final_estimator`. When True, the        `final_estimator` is trained on the predictions as well as the        original training data.</ins>     Attributes     ----------     estimators_ : list of estimator


Question: Stacking: add an option to use the original dataset when training finalestimator I think it will be readonable to add an option to use the original dataset when training finalestimator. This seems reasonable and has proved to be useful in some Kaggle competitions. Reference: implementation from mlxtend usefeaturesinsecondary : bool (default: False) If True, the meta-classifier will be trained both on the predictions of the original classifiers and the original dataset. If False, the meta-classifier will be trained only on the predictions of the original classifiers.

"""     def __init__(self, estimators, final_estimator=None, cv=None, n_jobs=None,                 verbose=0):                 passthrough=False, verbose=0):         super().__init__(             estimators=estimators,             final_estimator=final_estimator,             cv=cv,             stack_method="predict",             n_jobs=n_jobs,            passthrough=passthrough,             verbose=verbose         )


Question: imputationorder "ascending" and "descending" are inverted in IterativeImputer ImputerTriplets in fitted imputationsequence lists are appended according to imputationorder, but order is inverted

elif self.imputation_order == 'ascending':             n = len(frac_of_missing_values) - len(missing_values_idx)             ordered_idx = np.argsort(frac_of_missing_values,                                     kind='mergesort')[n:][::-1]                                     kind='mergesort')[n:]         elif self.imputation_order == 'descending':             n = len(frac_of_missing_values) - len(missing_values_idx)             ordered_idx = np.argsort(frac_of_missing_values,                                     kind='mergesort')[n:]                                     kind='mergesort')[n:][::-1]         elif self.imputation_order == 'random':             ordered_idx = missing_values_idx             self.random_state_.shuffle(ordered_idx)


Question: Use checksampleweight to consistently validate sampleweight We recently introduced which returns a validated array. We should use it consistently throughout the code base, instead of relying on custom and adhoc checks like or (which are now handled by ). Here's a list of the estimators/functions that could make use of it (mostly in or ): [x] CalibratedClassifierCV [x] DBSCAN [x] DummyClassifier [x] DummyRegressor [x] BaseBagging [x] BaseForest [x] BaseGradientBoosting [x] IsotonicRegression [x] KernelRidge [x] GaussianNB [x] BaseDiscreteNB [x] KernelDensity [x] BaseDecisionTree (I left-out the linearmodel module because it seems more involved there) Could be a decent sprint issue ? To know where a given class is defined, use e.g.

from ..utils import Bunch from ..utils import check_array from ..utils import check_random_state<ins>from ..utils.validation import _check_sample_weight</ins> from ..utils import compute_sample_weight from ..utils.multiclass import check_classification_targets from ..utils.validation import check_is_fitted


Question: Use checksampleweight to consistently validate sampleweight We recently introduced which returns a validated array. We should use it consistently throughout the code base, instead of relying on custom and adhoc checks like or (which are now handled by ). Here's a list of the estimators/functions that could make use of it (mostly in or ): [x] CalibratedClassifierCV [x] DBSCAN [x] DummyClassifier [x] DummyRegressor [x] BaseBagging [x] BaseForest [x] BaseGradientBoosting [x] IsotonicRegression [x] KernelRidge [x] GaussianNB [x] BaseDiscreteNB [x] KernelDensity [x] BaseDecisionTree (I left-out the linearmodel module because it seems more involved there) Could be a decent sprint issue ? To know where a given class is defined, use e.g.

"or larger than 1").format(max_leaf_nodes))          if sample_weight is not None:            if (getattr(sample_weight, "dtype", None) != DOUBLE or                    not sample_weight.flags.contiguous):                sample_weight = np.ascontiguousarray(                    sample_weight, dtype=DOUBLE)            if len(sample_weight.shape) > 1:                raise ValueError("Sample weights array has more "                                 "than one dimension: %d" %                                 len(sample_weight.shape))            if len(sample_weight) != n_samples:                raise ValueError("Number of weights=%d does not match "                                 "number of samples=%d" %                                 (len(sample_weight), n_samples))            sample_weight = _check_sample_weight(sample_weight, X, DOUBLE)          if expanded_class_weight is not None:             if sample_weight is not None:


Question: Return values of non converged affinity propagation clustering The affinity propagation Documentation states: "When the algorithm does not converge, it returns an empty array as clustercenterindices and -1 as label for each training sample." Example: I would expect that the clustering here (which does not converge) prints first an empty List and then [-1,-1,-1], however, I get [2] as cluster center and [0,0,0] as cluster labels. The only way I currently know if the clustering fails is if I use the verbose option, however that is very unhandy. A hacky solution is to check if maxiter == niter but it could have converged exactly 15 iterations before maxiter (although unlikely). I am not sure if this is intended behavior and the documentation is wrong? For my use-case within a bigger script, I would prefer to get back -1 values or have a property to check if it has converged, as otherwise, a user might not be aware that the clustering never converged. System: python: 3.6.7 (default, Nov 21 2018, 02:32:25) [GCC 4.8.2 (Red Hat 4.8.2-15)] executable: /home/jenniferh/Programs/anaconda3/envs/TFRDKit119/bin/python machine: Linux-4.15.0-52-generic-x8664-with-debian-stretch-sid BLAS: macros: SCIPYMKLH=None, HAVECBLAS=None libdirs: /home/jenniferh/Programs/anaconda3/envs/TFRDKit119/lib cblaslibs: mkl_rt, pthread Python deps: pip: 18.1 setuptools: 40.6.3 sklearn: 0.20.3 numpy: 1.15.4 scipy: 1.2.0 Cython: 0.29.2 pandas: 0.23.4

unconverged = (np.sum((se == convergence_iter) + (se == 0))                            != n_samples)             if (not unconverged and (K > 0)) or (it == max_iter):                never_converged = False                 if verbose:                     print("Converged after %d iterations." % it)                 break     else:        never_converged = True         if verbose:             print("Did not converge")      I = np.flatnonzero(E)     K = I.size  # Identify exemplars     if K > 0:    if K > 0 and not never_converged:         c = np.argmax(S[:, I], axis=1)         c[I] = np.arange(K)  # Identify clusters         # Refine the final set of exemplars and clusters and return results


Question: Return values of non converged affinity propagation clustering The affinity propagation Documentation states: "When the algorithm does not converge, it returns an empty array as clustercenterindices and -1 as label for each training sample." Example: I would expect that the clustering here (which does not converge) prints first an empty List and then [-1,-1,-1], however, I get [2] as cluster center and [0,0,0] as cluster labels. The only way I currently know if the clustering fails is if I use the verbose option, however that is very unhandy. A hacky solution is to check if maxiter == niter but it could have converged exactly 15 iterations before maxiter (although unlikely). I am not sure if this is intended behavior and the documentation is wrong? For my use-case within a bigger script, I would prefer to get back -1 values or have a property to check if it has converged, as otherwise, a user might not be aware that the clustering never converged. System: python: 3.6.7 (default, Nov 21 2018, 02:32:25) [GCC 4.8.2 (Red Hat 4.8.2-15)] executable: /home/jenniferh/Programs/anaconda3/envs/TFRDKit119/bin/python machine: Linux-4.15.0-52-generic-x8664-with-debian-stretch-sid BLAS: macros: SCIPYMKLH=None, HAVECBLAS=None libdirs: /home/jenniferh/Programs/anaconda3/envs/TFRDKit119/lib cblaslibs: mkl_rt, pthread Python deps: pip: 18.1 setuptools: 40.6.3 sklearn: 0.20.3 numpy: 1.15.4 scipy: 1.2.0 Cython: 0.29.2 pandas: 0.23.4

Cluster labels.         """         check_is_fitted(self)<ins>        X = check_array(X)</ins>         if not hasattr(self, "cluster_centers_"):             raise ValueError("Predict method is not supported when "                              "affinity='precomputed'.")


Question: Nested Cross Validation for precomputed KNN A nested cross validation prediction using a knn with precomputed metric raised an error Should return the predictions made by the model as the following code produces: sklearn 0.20.2

def _estimator_type(self):         return self.estimator._estimator_type <ins>    @property    def _pairwise(self):        # allows cross-validation to see 'precomputed' metrics        return getattr(self.estimator, '_pairwise', False)</ins>     def score(self, X, y=None):         """Returns the score on the given data, if the estimator has been refit.


Question: regression in input validation of clustering metrics ValueError: could not convert string to float: 'b' while works with a warning? this worked in 0.21.1 without a warning (as I think it should) Edit by I removed the in the second code snippet.

The predicted labels.     """     labels_true = check_array(        labels_true, ensure_2d=False, ensure_min_samples=0        labels_true, ensure_2d=False, ensure_min_samples=0, dtype=None,     )     labels_pred = check_array(        labels_pred, ensure_2d=False, ensure_min_samples=0        labels_pred, ensure_2d=False, ensure_min_samples=0, dtype=None,     )      # input checks


Question: ENH: add normalize parameter to metrics.classification.confusionmatrix Allows to get a normalized confusion matrix directly from the function call. I use frequently and find the need to always normalize the matrix manually maybe unnecessary. I am aware of the fact that other functions like already have this exact functionality implemented, so probably the lack of the parameter is intentional and I'm missing the why. But in case its not intentional you might find this contribution useful :).

return _weighted_sum(score, sample_weight, normalize)  def confusion_matrix(y_true, y_pred, labels=None, sample_weight=None):    """Compute confusion matrix to evaluate the accuracy of a classificationdef confusion_matrix(y_true, y_pred, labels=None, sample_weight=None,                     normalize=None):    """Compute confusion matrix to evaluate the accuracy of a classification.      By definition a confusion matrix :math:`C` is such that :math:`C_{i, j}`     is equal to the number of observations known to be in group :math:`i` and


Question: ENH: add normalize parameter to metrics.classification.confusionmatrix Allows to get a normalized confusion matrix directly from the function call. I use frequently and find the need to always normalize the matrix manually maybe unnecessary. I am aware of the fact that other functions like already have this exact functionality implemented, so probably the lack of the parameter is intentional and I'm missing the why. But in case its not intentional you might find this contribution useful :).

Parameters     ----------    y_true : array, shape = [n_samples]    y_true : array-like of shape (n_samples,)         Ground truth (correct) target values.     y_pred : array, shape = [n_samples]    y_pred : array-like of shape (n_samples,)         Estimated targets as returned by a classifier.     labels : array, shape = [n_classes], optional    labels : array-like of shape (n_classes), default=None         List of labels to index the matrix. This may be used to reorder         or select a subset of labels.        If none is given, those that appear at least once        If ``None`` is given, those that appear at least once         in ``y_true`` or ``y_pred`` are used in sorted order.      sample_weight : array-like of shape (n_samples,), default=None         Sample weights.     normalize : {'true', 'pred', 'all'}, default=None        Normalizes confusion matrix over the true (rows), predicted (columns)        conditions or all the population. If None, confusion matrix will not be        normalized.     Returns     -------     C : ndarray of shape (n_classes, n_classes)        Confusion matrix        Confusion matrix.      References     ----------


Question: ENH: add normalize parameter to metrics.classification.confusionmatrix Allows to get a normalized confusion matrix directly from the function call. I use frequently and find the need to always normalize the matrix manually maybe unnecessary. I am aware of the fact that other functions like already have this exact functionality implemented, so probably the lack of the parameter is intentional and I'm missing the why. But in case its not intentional you might find this contribution useful :).

else:         dtype = np.float64     CM = coo_matrix((sample_weight, (y_true, y_pred)),    cm = coo_matrix((sample_weight, (y_true, y_pred)),                     shape=(n_labels, n_labels), dtype=dtype,                     ).toarray()     return CM    with np.errstate(all='ignore'):        if normalize == 'true':            cm = cm / cm.sum(axis=1, keepdims=True)        elif normalize == 'pred':            cm = cm / cm.sum(axis=0, keepdims=True)        elif normalize == 'all':            cm = cm / cm.sum()        cm = np.nan_to_num(cm)    return cm   def multilabel_confusion_matrix(y_true, y_pred, sample_weight=None,diff --git a/sklearn/metrics/_plot/confusion_matrix.py b/sklearn/metrics/_plot/confusion_matrix.py-- a/sklearn/metrics/_plot/confusion_matrix.py++ b/sklearn/metrics/_plot/confusion_matrix.py


Question: ENH: add normalize parameter to metrics.classification.confusionmatrix Allows to get a normalized confusion matrix directly from the function call. I use frequently and find the need to always normalize the matrix manually maybe unnecessary. I am aware of the fact that other functions like already have this exact functionality implemented, so probably the lack of the parameter is intentional and I'm missing the why. But in case its not intentional you might find this contribution useful :).

Includes values in confusion matrix.      normalize : {'true', 'pred', 'all'}, default=None        Normalizes confusion matrix over the true (rows), predicited (columns)        Normalizes confusion matrix over the true (rows), predicted (columns)         conditions or all the population. If None, confusion matrix will not be         normalized.


Question: ENH: add normalize parameter to metrics.classification.confusionmatrix Allows to get a normalized confusion matrix directly from the function call. I use frequently and find the need to always normalize the matrix manually maybe unnecessary. I am aware of the fact that other functions like already have this exact functionality implemented, so probably the lack of the parameter is intentional and I'm missing the why. But in case its not intentional you might find this contribution useful :).

y_pred = estimator.predict(X)     cm = confusion_matrix(y_true, y_pred, sample_weight=sample_weight,                          labels=labels)    if normalize == 'true':        cm = cm / cm.sum(axis=1, keepdims=True)    elif normalize == 'pred':        cm = cm / cm.sum(axis=0, keepdims=True)    elif normalize == 'all':        cm = cm / cm.sum()                          labels=labels, normalize=normalize)      if display_labels is None:         if labels is None:


Question: LabelPropagation raises TypeError: A sparse matrix was passed LabelPropagation (and LabelSpreading) error out for sparse matrices. Sparse case should work as does the dense one. Changing in line 224 to seems to fix the problem for me (BTW: a similar check accepting sparse matrices is done in BaseLabelPropagations predictproba at line 189). This fix also heals LabelSpreading. FIX LabelPropagation handling of sparce matrices Label propagation and spreading allow to classify using sparse data according to documentation. Tests only covered the dense case. Newly coverage for sparse matrices allows to reproduce the problem in . The proposed fix in works for the extended tests. Supporting scipy's dokmatrix produces the UserWarning "Can't check dok sparse matrix for nan or inf.". So this format seems to be unsuitable? fails for sparse matrices

Parameters         ----------        X : array-like of shape (n_samples, n_features)        X : {array-like, sparse matrix} of shape (n_samples, n_features)             Training data, where `n_samples` is the number of samples             and `n_features` is the number of features.


Question: LabelPropagation raises TypeError: A sparse matrix was passed LabelPropagation (and LabelSpreading) error out for sparse matrices. Sparse case should work as does the dense one. Changing in line 224 to seems to fix the problem for me (BTW: a similar check accepting sparse matrices is done in BaseLabelPropagations predictproba at line 189). This fix also heals LabelSpreading. FIX LabelPropagation handling of sparce matrices Label propagation and spreading allow to classify using sparse data according to documentation. Tests only covered the dense case. Newly coverage for sparse matrices allows to reproduce the problem in . The proposed fix in works for the extended tests. Supporting scipy's dokmatrix produces the UserWarning "Can't check dok sparse matrix for nan or inf.". So this format seems to be unsuitable? fails for sparse matrices

Returns the instance itself.         """         self._validate_params()        X, y = self._validate_data(X, y)        X, y = self._validate_data(            X,            y,            accept_sparse=["csr", "csc"],            reset=True,        )         self.X_ = X         check_classification_targets(y)


Question: LabelPropagation raises TypeError: A sparse matrix was passed LabelPropagation (and LabelSpreading) error out for sparse matrices. Sparse case should work as does the dense one. Changing in line 224 to seems to fix the problem for me (BTW: a similar check accepting sparse matrices is done in BaseLabelPropagations predictproba at line 189). This fix also heals LabelSpreading. FIX LabelPropagation handling of sparce matrices Label propagation and spreading allow to classify using sparse data according to documentation. Tests only covered the dense case. Newly coverage for sparse matrices allows to reproduce the problem in . The proposed fix in works for the extended tests. Supporting scipy's dokmatrix produces the UserWarning "Can't check dok sparse matrix for nan or inf.". So this format seems to be unsuitable? fails for sparse matrices

Attributes     ----------    X_ : ndarray of shape (n_samples, n_features)    X_ : {array-like, sparse matrix} of shape (n_samples, n_features)         Input array.      classes_ : ndarray of shape (n_classes,)


Question: LabelPropagation raises TypeError: A sparse matrix was passed LabelPropagation (and LabelSpreading) error out for sparse matrices. Sparse case should work as does the dense one. Changing in line 224 to seems to fix the problem for me (BTW: a similar check accepting sparse matrices is done in BaseLabelPropagations predictproba at line 189). This fix also heals LabelSpreading. FIX LabelPropagation handling of sparce matrices Label propagation and spreading allow to classify using sparse data according to documentation. Tests only covered the dense case. Newly coverage for sparse matrices allows to reproduce the problem in . The proposed fix in works for the extended tests. Supporting scipy's dokmatrix produces the UserWarning "Can't check dok sparse matrix for nan or inf.". So this format seems to be unsuitable? fails for sparse matrices


Question: GPR enforce before calling In , sampling in the prior before calling via will assume that is made of a single target. However, this is not necessarily the case. Therefore, the shape of the output of before and after is different. In order to solve this inconsistency, we need to introduce a new parameter . Before calling this parameter should be explicitly set by the user. After , we can use the information of the target seen during without explicitly setting the parameter.

which might cause predictions to change if the data is modified         externally. <ins>    n_targets : int, default=None        The number of dimensions of the target values. Used to decide the number        of outputs when sampling from the prior distributions (i.e. calling        :meth:`sample_y` before :meth:`fit`). This parameter is ignored once        :meth:`fit` has been called.        .. versionadded:: 1.3</ins>     random_state : int, RandomState instance or None, default=None         Determines random number generation used to initialize the centers.         Pass an int for reproducible results across multiple function calls.


Question: GPR enforce before calling In , sampling in the prior before calling via will assume that is made of a single target. However, this is not necessarily the case. Therefore, the shape of the output of before and after is different. In order to solve this inconsistency, we need to introduce a new parameter . Before calling this parameter should be explicitly set by the user. After , we can use the information of the target seen during without explicitly setting the parameter.

"n_restarts_optimizer": [Interval(Integral, 0, None, closed="left")],         "normalize_y": ["boolean"],         "copy_X_train": ["boolean"],<ins>        "n_targets": [Interval(Integral, 1, None, closed="left"), None],</ins>         "random_state": ["random_state"],     }


Question: GPR enforce before calling In , sampling in the prior before calling via will assume that is made of a single target. However, this is not necessarily the case. Therefore, the shape of the output of before and after is different. In order to solve this inconsistency, we need to introduce a new parameter . Before calling this parameter should be explicitly set by the user. After , we can use the information of the target seen during without explicitly setting the parameter.

n_restarts_optimizer=0,         normalize_y=False,         copy_X_train=True,<ins>        n_targets=None,</ins>         random_state=None,     ):         self.kernel = kernel


Question: GPR enforce before calling In , sampling in the prior before calling via will assume that is made of a single target. However, this is not necessarily the case. Therefore, the shape of the output of before and after is different. In order to solve this inconsistency, we need to introduce a new parameter . Before calling this parameter should be explicitly set by the user. After , we can use the information of the target seen during without explicitly setting the parameter.

self.n_restarts_optimizer = n_restarts_optimizer         self.normalize_y = normalize_y         self.copy_X_train = copy_X_train<ins>        self.n_targets = n_targets</ins>         self.random_state = random_state      def fit(self, X, y):


Question: GPR enforce before calling In , sampling in the prior before calling via will assume that is made of a single target. However, this is not necessarily the case. Therefore, the shape of the output of before and after is different. In order to solve this inconsistency, we need to introduce a new parameter . Before calling this parameter should be explicitly set by the user. After , we can use the information of the target seen during without explicitly setting the parameter.

dtype=dtype,         ) <ins>        n_targets_seen = y.shape[1] if y.ndim > 1 else 1        if self.n_targets is not None and n_targets_seen != self.n_targets:            raise ValueError(                "The number of targets seen in `y` is different from the parameter "                f"`n_targets`. Got {n_targets_seen} != {self.n_targets}."            )</ins>         # Normalize target value         if self.normalize_y:             self._y_train_mean = np.mean(y, axis=0)


Question: GPR enforce before calling In , sampling in the prior before calling via will assume that is made of a single target. However, this is not necessarily the case. Therefore, the shape of the output of before and after is different. In order to solve this inconsistency, we need to introduce a new parameter . Before calling this parameter should be explicitly set by the user. After , we can use the information of the target seen during without explicitly setting the parameter.

)             else:                 kernel = self.kernel            y_mean = np.zeros(X.shape[0])            n_targets = self.n_targets if self.n_targets is not None else 1            y_mean = np.zeros(shape=(X.shape[0], n_targets)).squeeze()             if return_cov:                 y_cov = kernel(X)                if n_targets > 1:                    y_cov = np.repeat(                        np.expand_dims(y_cov, -1), repeats=n_targets, axis=-1                    )                 return y_mean, y_cov             elif return_std:                 y_var = kernel.diag(X)                if n_targets > 1:                    y_var = np.repeat(                        np.expand_dims(y_var, -1), repeats=n_targets, axis=-1                    )                 return y_mean, np.sqrt(y_var)             else:                 return y_mean


Question: [MRG] Fixes sklearn.metrics.silhouette_samples for sparse matrices <!-- Thanks for contributing a pull request! Please ensure you have taken a look at the contribution guidelines: -- The changes update the reduce function used for computing the intra-cluster and inter-cluster distances. The current version is failing at, a) the pre-computed check for sparse matrices while getting the diagonal elements b) when trying to index a sparse matrix to pass weights to np.bincount function <!-- Please be aware that we are a loose team of volunteers so patience is necessary; assistance handling other issues is very welcome. We value all user contributions, no matter how minor they are. If we are slow to review, either the pull request needs some benchmarking, tinkering, convincing, etc. or more likely the reviewers are simply busy. In either case, we ask for your understanding during the review process. For more information, see our FAQ on this topic: http://scikit- Thanks for contributing! --

import functools  import numpy as np<ins>from scipy.sparse import issparse</ins>  from ...utils import check_random_state from ...utils import check_X_y


Question: [MRG] Fixes sklearn.metrics.silhouette_samples for sparse matrices <!-- Thanks for contributing a pull request! Please ensure you have taken a look at the contribution guidelines: -- The changes update the reduce function used for computing the intra-cluster and inter-cluster distances. The current version is failing at, a) the pre-computed check for sparse matrices while getting the diagonal elements b) when trying to index a sparse matrix to pass weights to np.bincount function <!-- Please be aware that we are a loose team of volunteers so patience is necessary; assistance handling other issues is very welcome. We value all user contributions, no matter how minor they are. If we are slow to review, either the pull request needs some benchmarking, tinkering, convincing, etc. or more likely the reviewers are simply busy. In either case, we ask for your understanding during the review process. For more information, see our FAQ on this topic: http://scikit- Thanks for contributing! --

Parameters     ----------    D_chunk : array-like of shape (n_chunk_samples, n_samples)        Precomputed distances for a chunk.    D_chunk : {array-like, sparse matrix} of shape (n_chunk_samples, n_samples)        Precomputed distances for a chunk. If a sparse matrix is provided,        only CSR format is accepted.     start : int         First index in the chunk.     labels : array-like of shape (n_samples,)


Question: [MRG] Fixes sklearn.metrics.silhouette_samples for sparse matrices <!-- Thanks for contributing a pull request! Please ensure you have taken a look at the contribution guidelines: -- The changes update the reduce function used for computing the intra-cluster and inter-cluster distances. The current version is failing at, a) the pre-computed check for sparse matrices while getting the diagonal elements b) when trying to index a sparse matrix to pass weights to np.bincount function <!-- Please be aware that we are a loose team of volunteers so patience is necessary; assistance handling other issues is very welcome. We value all user contributions, no matter how minor they are. If we are slow to review, either the pull request needs some benchmarking, tinkering, convincing, etc. or more likely the reviewers are simply busy. In either case, we ask for your understanding during the review process. For more information, see our FAQ on this topic: http://scikit- Thanks for contributing! --

label_freqs : array-like         Distribution of cluster labels in ``labels``.     """    n_chunk_samples = D_chunk.shape[0]     # accumulate distances from each sample to each cluster    clust_dists = np.zeros((len(D_chunk), len(label_freqs)), dtype=D_chunk.dtype)    for i in range(len(D_chunk)):        clust_dists[i] += np.bincount(            labels, weights=D_chunk[i], minlength=len(label_freqs)        )    cluster_distances = np.zeros(        (n_chunk_samples, len(label_freqs)), dtype=D_chunk.dtype    )     # intra_index selects intra-cluster distances within clust_dists    intra_index = (np.arange(len(D_chunk)), labels[start : start + len(D_chunk)])    # intra_clust_dists are averaged over cluster size outside this function    intra_clust_dists = clust_dists[intra_index]    if issparse(D_chunk):        if D_chunk.format != "csr":            raise TypeError(                "Expected CSR matrix. Please pass sparse matrix in CSR format."            )        for i in range(n_chunk_samples):            indptr = D_chunk.indptr            indices = D_chunk.indices[indptr[i] : indptr[i + 1]]            sample_weights = D_chunk.data[indptr[i] : indptr[i + 1]]            sample_labels = np.take(labels, indices)            cluster_distances[i] += np.bincount(                sample_labels, weights=sample_weights, minlength=len(label_freqs)            )    else:        for i in range(n_chunk_samples):            sample_weights = D_chunk[i]            sample_labels = labels            cluster_distances[i] += np.bincount(                sample_labels, weights=sample_weights, minlength=len(label_freqs)            )    # intra_index selects intra-cluster distances within cluster_distances    end = start + n_chunk_samples    intra_index = (np.arange(n_chunk_samples), labels[start:end])    # intra_cluster_distances are averaged over cluster size outside this function    intra_cluster_distances = cluster_distances[intra_index]     # of the remaining distances we normalise and extract the minimum    clust_dists[intra_index] = np.inf    clust_dists /= label_freqs    inter_clust_dists = clust_dists.min(axis=1)    return intra_clust_dists, inter_clust_dists    cluster_distances[intra_index] = np.inf    cluster_distances /= label_freqs    inter_cluster_distances = cluster_distances.min(axis=1)    return intra_cluster_distances, inter_cluster_distances   def silhouette_samples(X, labels, *, metric="euclidean", **kwds):


Question: [MRG] Fixes sklearn.metrics.silhouette_samples for sparse matrices <!-- Thanks for contributing a pull request! Please ensure you have taken a look at the contribution guidelines: -- The changes update the reduce function used for computing the intra-cluster and inter-cluster distances. The current version is failing at, a) the pre-computed check for sparse matrices while getting the diagonal elements b) when trying to index a sparse matrix to pass weights to np.bincount function <!-- Please be aware that we are a loose team of volunteers so patience is necessary; assistance handling other issues is very welcome. We value all user contributions, no matter how minor they are. If we are slow to review, either the pull request needs some benchmarking, tinkering, convincing, etc. or more likely the reviewers are simply busy. In either case, we ask for your understanding during the review process. For more information, see our FAQ on this topic: http://scikit- Thanks for contributing! --

Parameters     ----------    X : array-like of shape (n_samples_a, n_samples_a) if metric == \    X : {array-like, sparse matrix} of shape (n_samples_a, n_samples_a) if metric == \             "precomputed" or (n_samples_a, n_features) otherwise        An array of pairwise distances between samples, or a feature array.        An array of pairwise distances between samples, or a feature array. If        a sparse matrix is provided, CSR format should be favoured avoiding        an additional copy.      labels : array-like of shape (n_samples,)         Label values for each sample.


Question: [MRG] Fixes sklearn.metrics.silhouette_samples for sparse matrices <!-- Thanks for contributing a pull request! Please ensure you have taken a look at the contribution guidelines: -- The changes update the reduce function used for computing the intra-cluster and inter-cluster distances. The current version is failing at, a) the pre-computed check for sparse matrices while getting the diagonal elements b) when trying to index a sparse matrix to pass weights to np.bincount function <!-- Please be aware that we are a loose team of volunteers so patience is necessary; assistance handling other issues is very welcome. We value all user contributions, no matter how minor they are. If we are slow to review, either the pull request needs some benchmarking, tinkering, convincing, etc. or more likely the reviewers are simply busy. In either case, we ask for your understanding during the review process. For more information, see our FAQ on this topic: http://scikit- Thanks for contributing! --

.. [2] `Wikipedia entry on the Silhouette Coefficient        <https://en.wikipedia.org/wiki/Silhouette_(clustering)>`_     """    X, labels = check_X_y(X, labels, accept_sparse=["csc", "csr"])    X, labels = check_X_y(X, labels, accept_sparse=["csr"])      # Check for non-zero diagonal entries in precomputed distance matrix     if metric == "precomputed":


Question: [MRG] Fixes sklearn.metrics.silhouette_samples for sparse matrices <!-- Thanks for contributing a pull request! Please ensure you have taken a look at the contribution guidelines: -- The changes update the reduce function used for computing the intra-cluster and inter-cluster distances. The current version is failing at, a) the pre-computed check for sparse matrices while getting the diagonal elements b) when trying to index a sparse matrix to pass weights to np.bincount function <!-- Please be aware that we are a loose team of volunteers so patience is necessary; assistance handling other issues is very welcome. We value all user contributions, no matter how minor they are. If we are slow to review, either the pull request needs some benchmarking, tinkering, convincing, etc. or more likely the reviewers are simply busy. In either case, we ask for your understanding during the review process. For more information, see our FAQ on this topic: http://scikit- Thanks for contributing! --

)         if X.dtype.kind == "f":             atol = np.finfo(X.dtype).eps * 100            if np.any(np.abs(np.diagonal(X)) > atol):                raise ValueError(error_msg)        elif np.any(np.diagonal(X) != 0):  # integral dtype            raise ValueError(error_msg)            if np.any(np.abs(X.diagonal()) > atol):                raise error_msg        elif np.any(X.diagonal() != 0):  # integral dtype            raise error_msg      le = LabelEncoder()     labels = le.fit_transform(labels)


Question: Add meanaverageprecision Mean average precision (mAP) is a standard multi-class extension of average precision using OVR: (informationretrieval)#Meanaverage_precision Recently I prefer AP over AUC so I think it would be cool to add this. Maybe is interested? probably knows how to do this ;)

trapezoidal rule, which uses linear interpolation and can be too     optimistic. <del>    Note: this implementation is restricted to the binary classification task    or multilabel classification task.</del>     Read more in the :ref:`User Guide <precision_recall_f_measure_metrics>`.      Parameters


Question: Add meanaverageprecision Mean average precision (mAP) is a standard multi-class extension of average precision using OVR: (informationretrieval)#Meanaverage_precision Recently I prefer AP over AUC so I think it would be cool to add this. Maybe is interested? probably knows how to do this ;)

>>> y_scores = np.array([0.1, 0.4, 0.35, 0.8])     >>> average_precision_score(y_true, y_scores)     0.83...<ins>    >>> y_true = np.array([0, 0, 1, 1, 2, 2])    >>> y_scores = np.array([    ...     [0.7, 0.2, 0.1],    ...     [0.4, 0.3, 0.3],    ...     [0.1, 0.8, 0.1],    ...     [0.2, 0.3, 0.5],    ...     [0.4, 0.4, 0.2],    ...     [0.1, 0.2, 0.7],    ... ])    >>> average_precision_score(y_true, y_scores)    0.77...</ins>     """      def _binary_uninterpolated_average_precision(


Question: Add meanaverageprecision Mean average precision (mAP) is a standard multi-class extension of average precision using OVR: (informationretrieval)#Meanaverage_precision Recently I prefer AP over AUC so I think it would be cool to add this. Maybe is interested? probably knows how to do this ;)

return -np.sum(np.diff(recall) * np.array(precision)[:-1])      y_type = type_of_target(y_true, input_name="y_true")    if y_type == "multilabel-indicator" and pos_label != 1:        raise ValueError(            "Parameter pos_label is fixed to 1 for "            "multilabel-indicator y_true. Do not set "            "pos_label or set pos_label to 1."        )    elif y_type == "binary":        # Convert to Python primitive type to avoid NumPy type / Python str        # comparison. See https://github.com/numpy/numpy/issues/6784        present_labels = np.unique(y_true).tolist()    # Convert to Python primitive type to avoid NumPy type / Python str    # comparison. See https://github.com/numpy/numpy/issues/6784    present_labels = np.unique(y_true).tolist()    if y_type == "binary":         if len(present_labels) == 2 and pos_label not in present_labels:             raise ValueError(                 f"pos_label={pos_label} is not a valid label. It should be "                 f"one of {present_labels}"             )    elif y_type == "multilabel-indicator" and pos_label != 1:        raise ValueError(            "Parameter pos_label is fixed to 1 for multilabel-indicator y_true. "            "Do not set pos_label or set pos_label to 1."        )    elif y_type == "multiclass":        if pos_label != 1:            raise ValueError(                "Parameter pos_label is fixed to 1 for multiclass y_true. "                "Do not set pos_label or set pos_label to 1."            )        y_true = label_binarize(y_true, classes=present_labels)     average_precision = partial(         _binary_uninterpolated_average_precision, pos_label=pos_label     )


Question: Preserving dtypes for DataFrame output by transformers that do not modify the input values It would be nice to optionally preserve the dtypes of the input using pandas output for transformers . Dtypes can contain information relevant for later steps of the analyses. E.g. if I include pd.categorical columns to represent ordinal data and then select features using a sklearn transformer the columns will loose their categorical dtype. This means I loose important information for later analyses steps. This is not only relevant for the categorical dtypes, but could expand to others dtypes (existing, future and custom). Furthermore, this would allow to sequentially use ColumnTransformer while preserving the dtypes (maybe related to ). Currently, this behavior is not given as one can see with this code snippet (minimal example for illustration purposes): Output (using sklearn version '1.2.dev0'): The ouput shows that both the and are converted to in the dataframe output. Maybe one could adjust the to also allow to preserve the dtypes. This would mean one changes the to add: another argument to . If not None the outputted dataframe uses to set the . The of the could be provided to by if the dtypes is set to preserve in the config. One could adjust specific transformers for which this might be relevant. Such a solution would need more work and does not seem to be inline with the simplicity that pandas output provides to the user for every transformer. is also interested in this feature.

y="no_validation",         reset=True,         validate_separately=False,<ins>        cast_to_ndarray=True,</ins>         **check_params,     ):         """Validate input data and set or check the `n_features_in_` attribute.


Question: Preserving dtypes for DataFrame output by transformers that do not modify the input values It would be nice to optionally preserve the dtypes of the input using pandas output for transformers . Dtypes can contain information relevant for later steps of the analyses. E.g. if I include pd.categorical columns to represent ordinal data and then select features using a sklearn transformer the columns will loose their categorical dtype. This means I loose important information for later analyses steps. This is not only relevant for the categorical dtypes, but could expand to others dtypes (existing, future and custom). Furthermore, this would allow to sequentially use ColumnTransformer while preserving the dtypes (maybe related to ). Currently, this behavior is not given as one can see with this code snippet (minimal example for illustration purposes): Output (using sklearn version '1.2.dev0'): The ouput shows that both the and are converted to in the dataframe output. Maybe one could adjust the to also allow to preserve the dtypes. This would mean one changes the to add: another argument to . If not None the outputted dataframe uses to set the . The of the could be provided to by if the dtypes is set to preserve in the config. One could adjust specific transformers for which this might be relevant. Such a solution would need more work and does not seem to be inline with the simplicity that pandas output provides to the user for every transformer. is also interested in this feature.

`estimator=self` is automatically added to these dicts to generate             more informative error message in case of invalid input data. <ins>        cast_to_ndarray : bool, default=True            Cast `X` and `y` to ndarray with checks in `check_params`. If            `False`, `X` and `y` are unchanged and only `feature_names` and            `n_features_in_` are checked.</ins>         **check_params : kwargs             Parameters passed to :func:`sklearn.utils.check_array` or             :func:`sklearn.utils.check_X_y`. Ignored if validate_separately


Question: Preserving dtypes for DataFrame output by transformers that do not modify the input values It would be nice to optionally preserve the dtypes of the input using pandas output for transformers . Dtypes can contain information relevant for later steps of the analyses. E.g. if I include pd.categorical columns to represent ordinal data and then select features using a sklearn transformer the columns will loose their categorical dtype. This means I loose important information for later analyses steps. This is not only relevant for the categorical dtypes, but could expand to others dtypes (existing, future and custom). Furthermore, this would allow to sequentially use ColumnTransformer while preserving the dtypes (maybe related to ). Currently, this behavior is not given as one can see with this code snippet (minimal example for illustration purposes): Output (using sklearn version '1.2.dev0'): The ouput shows that both the and are converted to in the dataframe output. Maybe one could adjust the to also allow to preserve the dtypes. This would mean one changes the to add: another argument to . If not None the outputted dataframe uses to set the . The of the could be provided to by if the dtypes is set to preserve in the config. One could adjust specific transformers for which this might be relevant. Such a solution would need more work and does not seem to be inline with the simplicity that pandas output provides to the user for every transformer. is also interested in this feature.

if no_val_X and no_val_y:             raise ValueError("Validation should be done on X, y or both.")         elif not no_val_X and no_val_y:            X = check_array(X, input_name="X", **check_params)            if cast_to_ndarray:                X = check_array(X, input_name="X", **check_params)             out = X         elif no_val_X and not no_val_y:            y = _check_y(y, **check_params)            if cast_to_ndarray:                y = _check_y(y, **check_params) if cast_to_ndarray else y             out = y         else:            if validate_separately:            if validate_separately and cast_to_ndarray:                 # We need this because some estimators validate X and y                 # separately, and in general, separately calling check_array()                 # on X and y isn't equivalent to just calling check_X_y()diff --git a/sklearn/feature_selection/_base.py b/sklearn/feature_selection/_base.py-- a/sklearn/feature_selection/_base.py++ b/sklearn/feature_selection/_base.py


Question: Preserving dtypes for DataFrame output by transformers that do not modify the input values It would be nice to optionally preserve the dtypes of the input using pandas output for transformers . Dtypes can contain information relevant for later steps of the analyses. E.g. if I include pd.categorical columns to represent ordinal data and then select features using a sklearn transformer the columns will loose their categorical dtype. This means I loose important information for later analyses steps. This is not only relevant for the categorical dtypes, but could expand to others dtypes (existing, future and custom). Furthermore, this would allow to sequentially use ColumnTransformer while preserving the dtypes (maybe related to ). Currently, this behavior is not given as one can see with this code snippet (minimal example for illustration purposes): Output (using sklearn version '1.2.dev0'): The ouput shows that both the and are converted to in the dataframe output. Maybe one could adjust the to also allow to preserve the dtypes. This would mean one changes the to add: another argument to . If not None the outputted dataframe uses to set the . The of the could be provided to by if the dtypes is set to preserve in the config. One could adjust specific transformers for which this might be relevant. Such a solution would need more work and does not seem to be inline with the simplicity that pandas output provides to the user for every transformer. is also interested in this feature.

from ..cross_decomposition._pls import _PLS from ..utils import (     check_array,    safe_mask,     safe_sqr, ) from ..utils._tags import _safe_tagsfrom ..utils import _safe_indexingfrom ..utils._set_output import _get_output_config from ..utils.validation import _check_feature_names_in, check_is_fitted


Question: Preserving dtypes for DataFrame output by transformers that do not modify the input values It would be nice to optionally preserve the dtypes of the input using pandas output for transformers . Dtypes can contain information relevant for later steps of the analyses. E.g. if I include pd.categorical columns to represent ordinal data and then select features using a sklearn transformer the columns will loose their categorical dtype. This means I loose important information for later analyses steps. This is not only relevant for the categorical dtypes, but could expand to others dtypes (existing, future and custom). Furthermore, this would allow to sequentially use ColumnTransformer while preserving the dtypes (maybe related to ). Currently, this behavior is not given as one can see with this code snippet (minimal example for illustration purposes): Output (using sklearn version '1.2.dev0'): The ouput shows that both the and are converted to in the dataframe output. Maybe one could adjust the to also allow to preserve the dtypes. This would mean one changes the to add: another argument to . If not None the outputted dataframe uses to set the . The of the could be provided to by if the dtypes is set to preserve in the config. One could adjust specific transformers for which this might be relevant. Such a solution would need more work and does not seem to be inline with the simplicity that pandas output provides to the user for every transformer. is also interested in this feature.

X_r : array of shape [n_samples, n_selected_features]             The input samples with only the selected features.         """<ins>        # Preserve X when X is a dataframe and the output is configured to        # be pandas.        output_config_dense = _get_output_config("transform", estimator=self)["dense"]        preserve_X = hasattr(X, "iloc") and output_config_dense == "pandas"</ins>         # note: we use _safe_tags instead of _get_tags because this is a         # public Mixin.         X = self._validate_data(


Question: Preserving dtypes for DataFrame output by transformers that do not modify the input values It would be nice to optionally preserve the dtypes of the input using pandas output for transformers . Dtypes can contain information relevant for later steps of the analyses. E.g. if I include pd.categorical columns to represent ordinal data and then select features using a sklearn transformer the columns will loose their categorical dtype. This means I loose important information for later analyses steps. This is not only relevant for the categorical dtypes, but could expand to others dtypes (existing, future and custom). Furthermore, this would allow to sequentially use ColumnTransformer while preserving the dtypes (maybe related to ). Currently, this behavior is not given as one can see with this code snippet (minimal example for illustration purposes): Output (using sklearn version '1.2.dev0'): The ouput shows that both the and are converted to in the dataframe output. Maybe one could adjust the to also allow to preserve the dtypes. This would mean one changes the to add: another argument to . If not None the outputted dataframe uses to set the . The of the could be provided to by if the dtypes is set to preserve in the config. One could adjust specific transformers for which this might be relevant. Such a solution would need more work and does not seem to be inline with the simplicity that pandas output provides to the user for every transformer. is also interested in this feature.

dtype=None,             accept_sparse="csr",             force_all_finite=not _safe_tags(self, key="allow_nan"),<ins>            cast_to_ndarray=not preserve_X,</ins>             reset=False,         )         return self._transform(X)


Question: Preserving dtypes for DataFrame output by transformers that do not modify the input values It would be nice to optionally preserve the dtypes of the input using pandas output for transformers . Dtypes can contain information relevant for later steps of the analyses. E.g. if I include pd.categorical columns to represent ordinal data and then select features using a sklearn transformer the columns will loose their categorical dtype. This means I loose important information for later analyses steps. This is not only relevant for the categorical dtypes, but could expand to others dtypes (existing, future and custom). Furthermore, this would allow to sequentially use ColumnTransformer while preserving the dtypes (maybe related to ). Currently, this behavior is not given as one can see with this code snippet (minimal example for illustration purposes): Output (using sklearn version '1.2.dev0'): The ouput shows that both the and are converted to in the dataframe output. Maybe one could adjust the to also allow to preserve the dtypes. This would mean one changes the to add: another argument to . If not None the outputted dataframe uses to set the . The of the could be provided to by if the dtypes is set to preserve in the config. One could adjust specific transformers for which this might be relevant. Such a solution would need more work and does not seem to be inline with the simplicity that pandas output provides to the user for every transformer. is also interested in this feature.

" too noisy or the selection test too strict.",                 UserWarning,             )            if hasattr(X, "iloc"):                return X.iloc[:, :0]             return np.empty(0, dtype=X.dtype).reshape((X.shape[0], 0))        if len(mask) != X.shape[1]:            raise ValueError("X has a different shape than during fitting.")        return X[:, safe_mask(X, mask)]        return _safe_indexing(X, mask, axis=1)      def inverse_transform(self, X):         """Reverse the transformation operation.


Question: IterativeImputer has no parameter "fillvalue" In the first imputation round of , an initial value needs to be set for the missing values. From its : I have set the initial strategy to . However, I want to define this constant myself. So, as I look at the parameters for I find : When strategy == “constant”, fillvalue is used to replace all occurrences of missingvalues. If left to the default, fillvalue will be 0 when imputing numerical data and “missingvalue” for strings or object data types. Based on this information, one would assume that also has the parameter , but it does not. The parameter needs to be to for when is set to . If this parameter is , please also allow as , for optimal compatibility with decision tree-based estimators. No response No response

Which strategy to use to initialize the missing values. Same as the         `strategy` parameter in :class:`~sklearn.impute.SimpleImputer`. <ins>    fill_value : str or numerical value, default=None        When `strategy="constant"`, `fill_value` is used to replace all        occurrences of missing_values. For string or object data types,        `fill_value` must be a string.        If `None`, `fill_value` will be 0 when imputing numerical        data and "missing_value" for strings or object data types.        .. versionadded:: 1.3</ins>     imputation_order : {'ascending', 'descending', 'roman', 'arabic', \             'random'}, default='ascending'         The order in which the features will be imputed. Possible values:


Question: IterativeImputer has no parameter "fillvalue" In the first imputation round of , an initial value needs to be set for the missing values. From its : I have set the initial strategy to . However, I want to define this constant myself. So, as I look at the parameters for I find : When strategy == “constant”, fillvalue is used to replace all occurrences of missingvalues. If left to the default, fillvalue will be 0 when imputing numerical data and “missingvalue” for strings or object data types. Based on this information, one would assume that also has the parameter , but it does not. The parameter needs to be to for when is set to . If this parameter is , please also allow as , for optimal compatibility with decision tree-based estimators. No response No response

"initial_strategy": [             StrOptions({"mean", "median", "most_frequent", "constant"})         ],<ins>        "fill_value": "no_validation",  # any object is valid</ins>         "imputation_order": [             StrOptions({"ascending", "descending", "roman", "arabic", "random"})         ],


Question: IterativeImputer has no parameter "fillvalue" In the first imputation round of , an initial value needs to be set for the missing values. From its : I have set the initial strategy to . However, I want to define this constant myself. So, as I look at the parameters for I find : When strategy == “constant”, fillvalue is used to replace all occurrences of missingvalues. If left to the default, fillvalue will be 0 when imputing numerical data and “missingvalue” for strings or object data types. Based on this information, one would assume that also has the parameter , but it does not. The parameter needs to be to for when is set to . If this parameter is , please also allow as , for optimal compatibility with decision tree-based estimators. No response No response

tol=1e-3,         n_nearest_features=None,         initial_strategy="mean",<ins>        fill_value=None,</ins>         imputation_order="ascending",         skip_complete=False,         min_value=-np.inf,


Question: IterativeImputer has no parameter "fillvalue" In the first imputation round of , an initial value needs to be set for the missing values. From its : I have set the initial strategy to . However, I want to define this constant myself. So, as I look at the parameters for I find : When strategy == “constant”, fillvalue is used to replace all occurrences of missingvalues. If left to the default, fillvalue will be 0 when imputing numerical data and “missingvalue” for strings or object data types. Based on this information, one would assume that also has the parameter , but it does not. The parameter needs to be to for when is set to . If this parameter is , please also allow as , for optimal compatibility with decision tree-based estimators. No response No response

self.tol = tol         self.n_nearest_features = n_nearest_features         self.initial_strategy = initial_strategy<ins>        self.fill_value = fill_value</ins>         self.imputation_order = imputation_order         self.skip_complete = skip_complete         self.min_value = min_value


Question: IterativeImputer has no parameter "fillvalue" In the first imputation round of , an initial value needs to be set for the missing values. From its : I have set the initial strategy to . However, I want to define this constant myself. So, as I look at the parameters for I find : When strategy == “constant”, fillvalue is used to replace all occurrences of missingvalues. If left to the default, fillvalue will be 0 when imputing numerical data and “missingvalue” for strings or object data types. Based on this information, one would assume that also has the parameter , but it does not. The parameter needs to be to for when is set to . If this parameter is , please also allow as , for optimal compatibility with decision tree-based estimators. No response No response

self.initial_imputer_ = SimpleImputer(                 missing_values=self.missing_values,                 strategy=self.initial_strategy,<ins>                fill_value=self.fill_value,</ins>                 keep_empty_features=self.keep_empty_features,             )             X_filled = self.initial_imputer_.fit_transform(X)


Question: BUG logloss renormalizes the predictions renormalizes internally such that it sums to 1. This way, a really bad model, the predictions of which do not sum to 1, gets a better loss then it actually has. Result: Result:

The default value changed from `1e-15` to `"auto"` that is            equivalent to `np.finfo(y_pred.dtype).eps`. <ins>        .. deprecated:: 1.3           `eps` is deprecated in 1.3 and will be removed in 1.5.</ins>     normalize : bool, default=True         If true, return the mean loss per sample.         Otherwise, return the sum of the per-sample losses.


Question: BUG logloss renormalizes the predictions renormalizes internally such that it sums to 1. This way, a really bad model, the predictions of which do not sum to 1, gets a better loss then it actually has. Result: Result:

y_pred = check_array(         y_pred, ensure_2d=False, dtype=[np.float64, np.float32, np.float16]     )    eps = np.finfo(y_pred.dtype).eps if eps == "auto" else eps    if eps == "auto":        eps = np.finfo(y_pred.dtype).eps    else:        # TODO: Remove user defined eps in 1.5        warnings.warn(            "Setting the eps parameter is deprecated and will "            "be removed in 1.5. Instead eps will always have"            "a default value of `np.finfo(y_pred.dtype).eps`.",            FutureWarning,        )      check_consistent_length(y_pred, y_true, sample_weight)     lb = LabelBinarizer()


Question: BUG logloss renormalizes the predictions renormalizes internally such that it sums to 1. This way, a really bad model, the predictions of which do not sum to 1, gets a better loss then it actually has. Result: Result:

# Renormalize     y_pred_sum = y_pred.sum(axis=1)<ins>    if not np.isclose(y_pred_sum, 1, rtol=1e-15, atol=5 * eps).all():        warnings.warn(            "The y_pred values do not sum to one. Starting from 1.5 this"            "will result in an error.",            UserWarning,        )</ins>     y_pred = y_pred / y_pred_sum[:, np.newaxis]     loss = -xlogy(transformed_labels, y_pred).sum(axis=1)


Question: Make error message uniform when calling before While working , we found out that we are not consistent with the error type and message when calling before . From Please link the PRs you'll make with this issue so that I can update this list for all of us to know which estimators have been worked on: [x] AdditiveChi2Sampler() [x] Binarizer() [x] MaxAbsScaler() [x] MinMaxScaler() [x] Normalizer() [x] OrdinalEncoder() [x] PowerTransformer() [x] QuantileTransformer() [x] RobustScaler() [x] StackingClassifier() [x] StackingRegressor() [x] StandardScaler() [x] TfidfTransformer() [x] VotingClassifier() [x] VotingRegressor() [x] GaussianRandomProjection() [x] GenericUnivariateSelect() [x] IterativeImputer() [x] RFE() [x] RFECV() [x] SelectFdr() [x] SelectFpr() [x] SelectFromModel() [x] SelectFwe() [x] SelectKBest() [x] SelectPercentile() [x] SequentialFeatureSelector() [x] SparseRandomProjection() [x] VarianceThreshold() [x] KNNImputer() [x] SimpleImputer() [x] SplineTransformer() [x] DictVectorizer() [x] KBinsDiscretizer() [x] MissingIndicator() [x] IsotonicRegression() <details</detailsI assume that the most adequate error should be a asking to fit the estimator. WDYT?

safe_sqr, ) from ..utils._tags import _safe_tagsfrom ..utils.validation import _check_feature_names_infrom ..utils.validation import _check_feature_names_in, check_is_fitted   class SelectorMixin(TransformerMixin, metaclass=ABCMeta):


Question: Make error message uniform when calling before While working , we found out that we are not consistent with the error type and message when calling before . From Please link the PRs you'll make with this issue so that I can update this list for all of us to know which estimators have been worked on: [x] AdditiveChi2Sampler() [x] Binarizer() [x] MaxAbsScaler() [x] MinMaxScaler() [x] Normalizer() [x] OrdinalEncoder() [x] PowerTransformer() [x] QuantileTransformer() [x] RobustScaler() [x] StackingClassifier() [x] StackingRegressor() [x] StandardScaler() [x] TfidfTransformer() [x] VotingClassifier() [x] VotingRegressor() [x] GaussianRandomProjection() [x] GenericUnivariateSelect() [x] IterativeImputer() [x] RFE() [x] RFECV() [x] SelectFdr() [x] SelectFpr() [x] SelectFromModel() [x] SelectFwe() [x] SelectKBest() [x] SelectPercentile() [x] SequentialFeatureSelector() [x] SparseRandomProjection() [x] VarianceThreshold() [x] KNNImputer() [x] SimpleImputer() [x] SplineTransformer() [x] DictVectorizer() [x] KBinsDiscretizer() [x] MissingIndicator() [x] IsotonicRegression() <details</detailsI assume that the most adequate error should be a asking to fit the estimator. WDYT?

feature_names_out : ndarray of str objects             Transformed feature names.         """        check_is_fitted(self)         input_features = _check_feature_names_in(self, input_features)         return input_features[self.get_support()] diff --git a/sklearn/random_projection.py b/sklearn/random_projection.py-- a/sklearn/random_projection.py++ b/sklearn/random_projection.py


Question: Make error message uniform when calling before While working , we found out that we are not consistent with the error type and message when calling before . From Please link the PRs you'll make with this issue so that I can update this list for all of us to know which estimators have been worked on: [x] AdditiveChi2Sampler() [x] Binarizer() [x] MaxAbsScaler() [x] MinMaxScaler() [x] Normalizer() [x] OrdinalEncoder() [x] PowerTransformer() [x] QuantileTransformer() [x] RobustScaler() [x] StackingClassifier() [x] StackingRegressor() [x] StandardScaler() [x] TfidfTransformer() [x] VotingClassifier() [x] VotingRegressor() [x] GaussianRandomProjection() [x] GenericUnivariateSelect() [x] IterativeImputer() [x] RFE() [x] RFECV() [x] SelectFdr() [x] SelectFpr() [x] SelectFromModel() [x] SelectFwe() [x] SelectKBest() [x] SelectPercentile() [x] SequentialFeatureSelector() [x] SparseRandomProjection() [x] VarianceThreshold() [x] KNNImputer() [x] SimpleImputer() [x] SplineTransformer() [x] DictVectorizer() [x] KBinsDiscretizer() [x] MissingIndicator() [x] IsotonicRegression() <details</detailsI assume that the most adequate error should be a asking to fit the estimator. WDYT?

if self.compute_inverse_components:             self.inverse_components_ = self._compute_inverse_components()         return self    @property    def _n_features_out(self):        """Number of transformed output features.        # Required by ClassNamePrefixFeaturesOutMixin.get_feature_names_out.        self._n_features_out = self.n_components         Used by ClassNamePrefixFeaturesOutMixin.get_feature_names_out.        """        return self.n_components        return self      def inverse_transform(self, X):         """Project data back to its original space.


Question: sklearn.setconfig(transformoutput="pandas") breaks TSNE embeddings TSNE doesn't work when the I tracked down this bug in the sklearn codebase. The issue is here: What's happening is that returns a Pandas array under API, with the columns being named "pca0" and "pca1". So when is called, we get an IndexError, because you'd have to index with in this situation. Possible fix could be changing line 996 to this: which I am happy to make a PR to do unless somebody has a cleaner way. Cheers! No error is thrown, a 2-dimensional pandas array is returned

svd_solver="randomized",                 random_state=random_state,             )<ins>            # Always output a numpy array, no matter what is configured globally            pca.set_output(transform="default")</ins>             X_embedded = pca.fit_transform(X).astype(np.float32, copy=False)             # PCA is rescaled so that PC1 has standard deviation 1e-4 which is             # the default value for random initialization. See issue #18018.


Question: With MLPClassifer, when warmstart is True or coeffs are provided, fit doesn’t respect maxiters With MLPClassifer, when warmstart is True or coeffs are provided, fit doesn’t respect maxiters. The reason for this is, when fitting, max iteration check is equality (==) against When warmstart is true or coeffs are provided, initialize is not called; this method resets niter to 0. Based on this implementation, there is doubt as to the meaning of maxiter. Consider, if maxiter is 1 and fit terminates due to reaching maximum iterations, subsequent fittings with warmstart true will never terminate due to reaching maximum iterations. This is bug. An alternate interpretation is maxiter represents the maximum iterations per fit call. In this case, the implementation is also wrong. The later interpretation seems more reasonable. Iteration 1, loss = 0. ConvergenceWarning: Stochastic Optimizer: Maximum iterations reached and the optimization hasn't converged yet. Iteration 2, loss = 0. ConvergenceWarning: Stochastic Optimizer: Maximum iterations reached and the optimization hasn't converged yet. Iteration 3, loss = 0. ConvergenceWarning: Stochastic Optimizer: Maximum iterations reached and the optimization hasn't converged yet. Iteration 1, loss = 0. ConvergenceWarning: Stochastic Optimizer: Maximum iterations reached and the optimization hasn't converged yet. Iteration 2, loss = 0. Iteration 3, loss = 0. Windows-7-6.1.7601-SP1 Python 3.6.0 (v3.6.0:, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] NumPy 1.12.0 SciPy 0.18.1 Scikit-Learn 0.18.1

batch_size = np.clip(self.batch_size, 1, n_samples)          try:<ins>            self.n_iter_ = 0</ins>             for it in range(self.max_iter):                 if self.shuffle:                     # Only shuffle the sample indices instead of X and y to


Question: CalibratedClassifierCV doesn't work with CalibratedClassifierCV with isotonic regression doesn't work when we previously set . The IsotonicRegression seems to return a dataframe, which is a problem for in where it tries to put the dataframe in a numpy array row . It should not crash.

self._build_f(X, y)         return self     def transform(self, T):        """Transform new data by linear interpolation.        Parameters        ----------        T : array-like of shape (n_samples,) or (n_samples, 1)            Data to transform.    def _transform(self, T):        """`_transform` is called by both `transform` and `predict` methods.             .. versionchanged:: 0.24               Also accepts 2d array with 1 feature.        Since `transform` is wrapped to output arrays of specific types (e.g.        NumPy arrays, pandas DataFrame), we cannot make `predict` call `transform`        directly.         Returns        -------        y_pred : ndarray of shape (n_samples,)            The transformed data.        The above behaviour could be changed in the future, if we decide to output        other type of arrays when calling `predict`.         """         if hasattr(self, "X_thresholds_"):             dtype = self.X_thresholds_.dtype         else:


Question: CalibratedClassifierCV doesn't work with CalibratedClassifierCV with isotonic regression doesn't work when we previously set . The IsotonicRegression seems to return a dataframe, which is a problem for in where it tries to put the dataframe in a numpy array row . It should not crash.

return res <ins>    def transform(self, T):        """Transform new data by linear interpolation.        Parameters        ----------        T : array-like of shape (n_samples,) or (n_samples, 1)            Data to transform.            .. versionchanged:: 0.24               Also accepts 2d array with 1 feature.        Returns        -------        y_pred : ndarray of shape (n_samples,)            The transformed data.        """        return self._transform(T)</ins>     def predict(self, T):         """Predict new data by linear interpolation.


Question: CalibratedClassifierCV doesn't work with CalibratedClassifierCV with isotonic regression doesn't work when we previously set . The IsotonicRegression seems to return a dataframe, which is a problem for in where it tries to put the dataframe in a numpy array row . It should not crash.

y_pred : ndarray of shape (n_samples,)             Transformed data.         """        return self.transform(T)        return self._transform(T)      # We implement get_feature_names_out here instead of using     # `ClassNamePrefixFeaturesOutMixin`` because `input_features` are ignored.


Question: ColumnTransformer with pandas output can't handle transformers with no features Hi, ColumnTransformer doesn't deal well with transformers that apply to 0 features (categoricalfeatures in the example below) when using "pandas" as output. It seems steps with 0 features are not fitted, hence don't appear in ( l.856) and hence break the input to the function (l.859). Here is some code to reproduce the error. If you remove .set_output(transform="pandas") on the line before last, all works fine. If you remove the ("categorical", ...) step, it works fine too. The step with no features should be ignored. Here is the error message:

transformer_names = [                     t[0] for t in self._iter(fitted=True, replace_strings=True)                 ]                feature_names_outs = [X.columns for X in Xs]                # Selection of columns might be empty.                # Hence feature names are filtered for non-emptiness.                feature_names_outs = [X.columns for X in Xs if X.shape[1] != 0]                 names_out = self._add_prefix_for_feature_names_out(                     list(zip(transformer_names, feature_names_outs))                 )


Question: RandomForestClassifier classweight/maxsamples interaction can lead to ungraceful and nondescriptive failure The acceptable values for are . One possible option for is . However, for values of near zero and , the model fails with an unhelpful error related to having an empty array as an indexer. This is only likely to come up in a grid search, as it seems unlikely that someone would deliberately force a subsample of zero items. However, it might be useful to have a minimum of one sample, or it might be useful to fail gracefully with a more descriptive error. EITHER: No error is thrown OR

return max_samples      if isinstance(max_samples, Real):        return round(n_samples * max_samples)        return max(round(n_samples * max_samples), 1)   def _generate_sample_indices(random_state, n_samples, n_samples_bootstrap):


Question: RandomForestClassifier classweight/maxsamples interaction can lead to ungraceful and nondescriptive failure The acceptable values for are . One possible option for is . However, for values of near zero and , the model fails with an unhelpful error related to having an empty array as an indexer. This is only likely to come up in a grid search, as it seems unlikely that someone would deliberately force a subsample of zero items. However, it might be useful to have a minimum of one sample, or it might be useful to fail gracefully with a more descriptive error. EITHER: No error is thrown OR

- If None (default), then draw `X.shape[0]` samples.         - If int, then draw `max_samples` samples.        - If float, then draw `max_samples * X.shape[0]` samples. Thus,        - If float, then draw `max(round(n_samples * max_samples), 1)` samples. Thus,           `max_samples` should be in the interval `(0.0, 1.0]`.          .. versionadded:: 0.22


Question: RandomForestClassifier classweight/maxsamples interaction can lead to ungraceful and nondescriptive failure The acceptable values for are . One possible option for is . However, for values of near zero and , the model fails with an unhelpful error related to having an empty array as an indexer. This is only likely to come up in a grid search, as it seems unlikely that someone would deliberately force a subsample of zero items. However, it might be useful to have a minimum of one sample, or it might be useful to fail gracefully with a more descriptive error. EITHER: No error is thrown OR


Question: Support nullable pandas dtypes in I would like to be able to pass the nullable pandas dtypes ("Int64", "Float64", "boolean") into sklearn's function. Because the dtypes become dtype when converted to numpy arrays we get : Repro with sklearn 1.2.1 We should get the same behavior as when , , and dtypes are used, which is no error: Our current workaround is to convert the data to numpy arrays with the corresponding dtype that works prior to passing it into . No response_

if hasattr(y, "__array__") or isinstance(y, Sequence) or is_array_api:         # DeprecationWarning will be replaced by ValueError, see NEP 34         # https://numpy.org/neps/nep-0034-infer-dtype-is-object.html        check_y_kwargs = dict(            accept_sparse=True,            allow_nd=True,            force_all_finite=False,            ensure_2d=False,            ensure_min_samples=0,            ensure_min_features=0,        )         with warnings.catch_warnings():             warnings.simplefilter("error", np.VisibleDeprecationWarning)             try:                y = xp.asarray(y)            except (np.VisibleDeprecationWarning, ValueError):                y = check_array(y, dtype=None, **check_y_kwargs)            except (np.VisibleDeprecationWarning, ValueError) as e:                if str(e).startswith("Complex data not supported"):                    raise                 # dtype=object should be provided explicitly for ragged arrays,                 # see NEP 34                y = xp.asarray(y, dtype=object)                y = check_array(y, dtype=object, **check_y_kwargs)      if not (hasattr(y, "shape") and y.ndim == 2 and y.shape[1] > 1):         return False


Question: Support nullable pandas dtypes in I would like to be able to pass the nullable pandas dtypes ("Int64", "Float64", "boolean") into sklearn's function. Because the dtypes become dtype when converted to numpy arrays we get : Repro with sklearn 1.2.1 We should get the same behavior as when , , and dtypes are used, which is no error: Our current workaround is to convert the data to numpy arrays with the corresponding dtype that works prior to passing it into . No response_

# https://numpy.org/neps/nep-0034-infer-dtype-is-object.html     # We therefore catch both deprecation (NumPy < 1.24) warning and     # value error (NumPy >= 1.24).    check_y_kwargs = dict(        accept_sparse=True,        allow_nd=True,        force_all_finite=False,        ensure_2d=False,        ensure_min_samples=0,        ensure_min_features=0,    )     with warnings.catch_warnings():         warnings.simplefilter("error", np.VisibleDeprecationWarning)         if not issparse(y):             try:                y = xp.asarray(y)            except (np.VisibleDeprecationWarning, ValueError):                y = check_array(y, dtype=None, **check_y_kwargs)            except (np.VisibleDeprecationWarning, ValueError) as e:                if str(e).startswith("Complex data not supported"):                    raise                 # dtype=object should be provided explicitly for ragged arrays,                 # see NEP 34                y = xp.asarray(y, dtype=object)                y = check_array(y, dtype=object, **check_y_kwargs)      # The old sequence of sequences format     try:


Question: NDCG score doesn't work with binary relevance and a list of 1 element See this code example: It works correctly when the number of elements is bigger than 1: score and Computing does not make sense for single predictions. Throw an error if is a list of length 1 for NDCG and DCG. Test that this throws the appropriate error by running: <!-- Please be aware that we are a loose team of volunteers so patience is necessary; assistance handling other issues is very welcome. We value all user contributions, no matter how minor they are. If we are slow to review, either the pull request needs some benchmarking, tinkering, convincing, etc. or more likely the reviewers are simply busy. In either case, we ask for your understanding during the review process. For more information, see our FAQ on this topic: http://scikit- Thanks for contributing! --

if y_true.min() < 0:         # TODO(1.4): Replace warning w/ ValueError         warnings.warn(            "ndcg_score should not be used on negative y_true values. ndcg_score will"            " raise a ValueError on negative y_true values starting from version 1.4.",            "ndcg_score should not be used on negative y_true values. ndcg_score"            " will raise a ValueError on negative y_true values starting from"            " version 1.4.",             FutureWarning,         )    if y_true.ndim > 1 and y_true.shape[1] <= 1:        raise ValueError(            "Computing NDCG is only meaningful when there is more than 1 document. "            f"Got {y_true.shape[1]} instead."        )     _check_dcg_target_type(y_true)     gain = _ndcg_sample_scores(y_true, y_score, k=k, ignore_ties=ignore_ties)     return np.average(gain, weights=sample_weight)


Question: MLPRegressor.partialfit produces an error when earlystopping is True WIth , when using , works fine, but partial fit produces the following error: I think this is related to this change: If early stopping is not supported for partial fit, it should handle this gracefully. If this is a bug - it should be fixed.

)          # early_stopping in partial_fit doesn't make sense        early_stopping = self.early_stopping and not incremental        if self.early_stopping and incremental:            raise ValueError("partial_fit does not support early_stopping=True")        early_stopping = self.early_stopping         if early_stopping:             # don't stratify in multilabel classification             should_stratify = is_classifier(self) and self.n_outputs_ == 1