Talip7/scikit-learn-issues-multilabel huggingface dataset:
sklearn.metrics.logAUC

### Describe the workflow you want to enable

Computing logAUC values.

### Describe your proposed solution

 $LogAUC_\lambda=\frac{\sum_{i}^{where~x_i\ge\lambda} (\log_{10} x_{i+1} - \log_{10} x_i)(\frac{y_{i+1}+y_i}{2})}{\log_{10}\frac{1}{\lambda}}$

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

Practitioners are interested in early enrichment; logAUC values were created for that.

COMMENT:
"heuristically motivated": BEDROC AUC and LogAUC are motivated by very practical needs of people who use predictive models in production.
If two classifiers have the same AUC, which one should you use in production?
The one with the higher LogAUC would be a pretty smart choice.

Labels: New Feature, module:metrics, Needs Triage
sklearn.metrics.logAUC

### Describe the workflow you want to enable

Computing logAUC values.

### Describe your proposed solution

 $LogAUC_\lambda=\frac{\sum_{i}^{where~x_i\ge\lambda} (\log_{10} x_{i+1} - \log_{10} x_i)(\frac{y_{i+1}+y_i}{2})}{\log_{10}\frac{1}{\lambda}}$

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

Practitioners are interested in early enrichment; logAUC values were created for that.

COMMENT:
I'm -0 on adding it. Mostly because I think you should choose your model based on finding the point along the ROC curve that has the right tradeoff for your application. In that context I don't see the need for this.

For those who do want to use a summary statistic like logAUC I think `sklearn.metrics.make_scorer` makes it possible to write a scorer that implements this.

Labels: New Feature, module:metrics, Needs Triage
sklearn.metrics.logAUC

### Describe the workflow you want to enable

Computing logAUC values.

### Describe your proposed solution

 $LogAUC_\lambda=\frac{\sum_{i}^{where~x_i\ge\lambda} (\log_{10} x_{i+1} - \log_{10} x_i)(\frac{y_{i+1}+y_i}{2})}{\log_{10}\frac{1}{\lambda}}$

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

Practitioners are interested in early enrichment; logAUC values were created for that.

COMMENT:
I am -1 for including the metric. It does not mean that I'm discouraging practitioners from using it.

I reconcile the opinions of @betatim and @lorentzenchr where the proposed metric seems to be domain-specific and if one is searching to optimize it, I would encourage using `make_scorer`.

Labels: New Feature, module:metrics, Needs Triage
BisectingKmeans - intertia per cluster

### Describe the bug

Hi,

I have been using the sklearn package recently for some simple clustering. It appears to me that there is a typo in the BisectingKMeans class. In the `_inertia_per_cluster` method, we need to compute the inertia per-cluster. However, in the current version of the package we have the following:

```python
inertia_per_cluster = np.empty(centers.shape[1])
for label in range(centers.shape[0]):
  inertia_per_cluster[label] = ...
```

This will through an error unless the centers form a squared matrix, i.e. if we have the same number of clusters as we have scalar features... In order to solve this, we could simply replace the line 276 in [the corresponding file](https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/cluster/_bisect_k_means.py) with:

```python
inertia_per_cluster = np.empty(centers.shape[0]) # <- instead of [1]
```

### Steps/Code to Reproduce

```python
import numpy as np
from sklearn.cluster import BisectingKMeans

lut_size = 4
w = np.random.normal(size=(128,))
kmeans = BisectingKMeans(
    n_clusters=lut_size, random_state=0
).fit(w.reshape(-1, 1))
```

### Expected Results

no error should be thrown

### Actual Results

IndexError: index 1 is out of bounds for axis 0 with size 1

### Versions

```shell
Python dependencies:
      sklearn: 1.3.0
          pip: 23.2.1
   setuptools: 68.0.0
        numpy: 1.25.2
        scipy: 1.11.2
       Cython: None
       pandas: 2.0.3
   matplotlib: 3.7.2
       joblib: 1.3.2
threadpoolctl: 3.2.0
```

COMMENT:
Thanks for the report @EdouardYvinec. To be more precise, this function is only called after a bisection so there are always exactly 2 clusters, meaning that the issue only happens when n_features=1. I opened #27243 to fix it.

Labels: Bug
Implementation of Robust Random Cut Forest (RRCF) Algorithm

### Describe the workflow you want to enable

Enable users to perform robust anomaly detection using the Robust Random Cut Forest (RRCF) algorithm within the scikit-learn library.

### Describe your proposed solution

## Proposed Solution

I suggest the integration of the Robust Random Cut Forest (RRCF) [[paper](http://proceedings.mlr.press/v48/guha16.pdf)] algorithm into the scikit-learn library. The RRCF algorithm is a natural extension of the Isolation Forest. It presents improved capabilities in handling noisy data, outliers, and stream data scenarios.

The core idea behind RRCF is akin to the Isolation Forest—building binary search trees using random cuts in the input data space. The key distinction lies in the _probability of selecting a cut dimension being proportionate to the dimension's length_. This unique characteristic renders RRCF particularly suitable for scenarios where the Isolation Forest may not perform optimally.

## Implementation

The underlying tree and forest structure of RRCF closely resembles that of the existing iForest, as previously mentioned. The primary difference arises in the computation of anomaly scores, specifically within the `decision_function`.

Additionally, to cater to stream data scenarios, the implementation could (and it should) incorporate methods for efficient insertion and deletion of individual points, as mentioned in the paper.

### Existing Implementations

A pre-existing Python implementation of RRCF can be found at https://github.com/kLabUM/rrcf. This implementation appears to be well-structured and accurate, making it a potential reference for scikit-learn's integration.

I would greatly appreciate your consideration of this proposal. Thank you.

On a side note, please don't hesitate to point out any mistakes/enhancements in the proposal. I'll be glad to assist.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

This past summer, I had the opportunity to work with anomaly detection algorithms, and among them, I had the chance to closely explore the Robust Random Cut Forest (RRCF). Interestingly, I discovered that while scikit-learn already has Isolation Forest algorithm, RRCF implementation is still missing. This revelation has sparked a motivating drive within me to advocate for the integration of RRCF.

Although it is plausible that this discussion on this topic might have already been occurred, but I was not able to find anything related to RRCF in the issues section or in [scikit-learn-contrib](https://github.com/scikit-learn-contrib/scikit-learn-contrib) except in [this comment](https://github.com/scikit-learn/scikit-learn/issues/17307#issuecomment-632795440) (where the context is kind of different).

COMMENT:
@gjain-7 bro I am interested to work on this with you bro.

Labels: New Feature, Needs Decision, Needs Decision - Include Feature
Implementation of Robust Random Cut Forest (RRCF) Algorithm

### Describe the workflow you want to enable

Enable users to perform robust anomaly detection using the Robust Random Cut Forest (RRCF) algorithm within the scikit-learn library.

### Describe your proposed solution

## Proposed Solution

I suggest the integration of the Robust Random Cut Forest (RRCF) [[paper](http://proceedings.mlr.press/v48/guha16.pdf)] algorithm into the scikit-learn library. The RRCF algorithm is a natural extension of the Isolation Forest. It presents improved capabilities in handling noisy data, outliers, and stream data scenarios.

The core idea behind RRCF is akin to the Isolation Forest—building binary search trees using random cuts in the input data space. The key distinction lies in the _probability of selecting a cut dimension being proportionate to the dimension's length_. This unique characteristic renders RRCF particularly suitable for scenarios where the Isolation Forest may not perform optimally.

## Implementation

The underlying tree and forest structure of RRCF closely resembles that of the existing iForest, as previously mentioned. The primary difference arises in the computation of anomaly scores, specifically within the `decision_function`.

Additionally, to cater to stream data scenarios, the implementation could (and it should) incorporate methods for efficient insertion and deletion of individual points, as mentioned in the paper.

### Existing Implementations

A pre-existing Python implementation of RRCF can be found at https://github.com/kLabUM/rrcf. This implementation appears to be well-structured and accurate, making it a potential reference for scikit-learn's integration.

I would greatly appreciate your consideration of this proposal. Thank you.

On a side note, please don't hesitate to point out any mistakes/enhancements in the proposal. I'll be glad to assist.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

This past summer, I had the opportunity to work with anomaly detection algorithms, and among them, I had the chance to closely explore the Robust Random Cut Forest (RRCF). Interestingly, I discovered that while scikit-learn already has Isolation Forest algorithm, RRCF implementation is still missing. This revelation has sparked a motivating drive within me to advocate for the integration of RRCF.

Although it is plausible that this discussion on this topic might have already been occurred, but I was not able to find anything related to RRCF in the issues section or in [scikit-learn-contrib](https://github.com/scikit-learn-contrib/scikit-learn-contrib) except in [this comment](https://github.com/scikit-learn/scikit-learn/issues/17307#issuecomment-632795440) (where the context is kind of different).

COMMENT:
> do you know if there is someone around who is interested in isolation forest and might have an overview over the topic/methods in this area?

I am 🤚🏻 (if that counts)

Labels: New Feature, Needs Decision, Needs Decision - Include Feature
Implementation of Robust Random Cut Forest (RRCF) Algorithm

### Describe the workflow you want to enable

Enable users to perform robust anomaly detection using the Robust Random Cut Forest (RRCF) algorithm within the scikit-learn library.

### Describe your proposed solution

## Proposed Solution

I suggest the integration of the Robust Random Cut Forest (RRCF) [[paper](http://proceedings.mlr.press/v48/guha16.pdf)] algorithm into the scikit-learn library. The RRCF algorithm is a natural extension of the Isolation Forest. It presents improved capabilities in handling noisy data, outliers, and stream data scenarios.

The core idea behind RRCF is akin to the Isolation Forest—building binary search trees using random cuts in the input data space. The key distinction lies in the _probability of selecting a cut dimension being proportionate to the dimension's length_. This unique characteristic renders RRCF particularly suitable for scenarios where the Isolation Forest may not perform optimally.

## Implementation

The underlying tree and forest structure of RRCF closely resembles that of the existing iForest, as previously mentioned. The primary difference arises in the computation of anomaly scores, specifically within the `decision_function`.

Additionally, to cater to stream data scenarios, the implementation could (and it should) incorporate methods for efficient insertion and deletion of individual points, as mentioned in the paper.

### Existing Implementations

A pre-existing Python implementation of RRCF can be found at https://github.com/kLabUM/rrcf. This implementation appears to be well-structured and accurate, making it a potential reference for scikit-learn's integration.

I would greatly appreciate your consideration of this proposal. Thank you.

On a side note, please don't hesitate to point out any mistakes/enhancements in the proposal. I'll be glad to assist.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

This past summer, I had the opportunity to work with anomaly detection algorithms, and among them, I had the chance to closely explore the Robust Random Cut Forest (RRCF). Interestingly, I discovered that while scikit-learn already has Isolation Forest algorithm, RRCF implementation is still missing. This revelation has sparked a motivating drive within me to advocate for the integration of RRCF.

Although it is plausible that this discussion on this topic might have already been occurred, but I was not able to find anything related to RRCF in the issues section or in [scikit-learn-contrib](https://github.com/scikit-learn-contrib/scikit-learn-contrib) except in [this comment](https://github.com/scikit-learn/scikit-learn/issues/17307#issuecomment-632795440) (where the context is kind of different).

COMMENT:
Re open source, please check https://github.com/aws/random-cut-forest-by-aws. This is also used in OpenSearch.

Labels: New Feature, Needs Decision, Needs Decision - Include Feature
Implementation of Robust Random Cut Forest (RRCF) Algorithm

### Describe the workflow you want to enable

Enable users to perform robust anomaly detection using the Robust Random Cut Forest (RRCF) algorithm within the scikit-learn library.

### Describe your proposed solution

## Proposed Solution

I suggest the integration of the Robust Random Cut Forest (RRCF) [[paper](http://proceedings.mlr.press/v48/guha16.pdf)] algorithm into the scikit-learn library. The RRCF algorithm is a natural extension of the Isolation Forest. It presents improved capabilities in handling noisy data, outliers, and stream data scenarios.

The core idea behind RRCF is akin to the Isolation Forest—building binary search trees using random cuts in the input data space. The key distinction lies in the _probability of selecting a cut dimension being proportionate to the dimension's length_. This unique characteristic renders RRCF particularly suitable for scenarios where the Isolation Forest may not perform optimally.

## Implementation

The underlying tree and forest structure of RRCF closely resembles that of the existing iForest, as previously mentioned. The primary difference arises in the computation of anomaly scores, specifically within the `decision_function`.

Additionally, to cater to stream data scenarios, the implementation could (and it should) incorporate methods for efficient insertion and deletion of individual points, as mentioned in the paper.

### Existing Implementations

A pre-existing Python implementation of RRCF can be found at https://github.com/kLabUM/rrcf. This implementation appears to be well-structured and accurate, making it a potential reference for scikit-learn's integration.

I would greatly appreciate your consideration of this proposal. Thank you.

On a side note, please don't hesitate to point out any mistakes/enhancements in the proposal. I'll be glad to assist.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

This past summer, I had the opportunity to work with anomaly detection algorithms, and among them, I had the chance to closely explore the Robust Random Cut Forest (RRCF). Interestingly, I discovered that while scikit-learn already has Isolation Forest algorithm, RRCF implementation is still missing. This revelation has sparked a motivating drive within me to advocate for the integration of RRCF.

Although it is plausible that this discussion on this topic might have already been occurred, but I was not able to find anything related to RRCF in the issues section or in [scikit-learn-contrib](https://github.com/scikit-learn-contrib/scikit-learn-contrib) except in [this comment](https://github.com/scikit-learn/scikit-learn/issues/17307#issuecomment-632795440) (where the context is kind of different).

COMMENT:
> This is constant throughout the tree, so the vector of probabilities to sample each column remain fix at each split node?

As per my understanding, it depends on max-min of that node. So it would change.

btw @sudiptoguha is the co-author of this paper

Labels: New Feature, Needs Decision, Needs Decision - Include Feature
Implementation of Robust Random Cut Forest (RRCF) Algorithm

### Describe the workflow you want to enable

Enable users to perform robust anomaly detection using the Robust Random Cut Forest (RRCF) algorithm within the scikit-learn library.

### Describe your proposed solution

## Proposed Solution

I suggest the integration of the Robust Random Cut Forest (RRCF) [[paper](http://proceedings.mlr.press/v48/guha16.pdf)] algorithm into the scikit-learn library. The RRCF algorithm is a natural extension of the Isolation Forest. It presents improved capabilities in handling noisy data, outliers, and stream data scenarios.

The core idea behind RRCF is akin to the Isolation Forest—building binary search trees using random cuts in the input data space. The key distinction lies in the _probability of selecting a cut dimension being proportionate to the dimension's length_. This unique characteristic renders RRCF particularly suitable for scenarios where the Isolation Forest may not perform optimally.

## Implementation

The underlying tree and forest structure of RRCF closely resembles that of the existing iForest, as previously mentioned. The primary difference arises in the computation of anomaly scores, specifically within the `decision_function`.

Additionally, to cater to stream data scenarios, the implementation could (and it should) incorporate methods for efficient insertion and deletion of individual points, as mentioned in the paper.

### Existing Implementations

A pre-existing Python implementation of RRCF can be found at https://github.com/kLabUM/rrcf. This implementation appears to be well-structured and accurate, making it a potential reference for scikit-learn's integration.

I would greatly appreciate your consideration of this proposal. Thank you.

On a side note, please don't hesitate to point out any mistakes/enhancements in the proposal. I'll be glad to assist.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

This past summer, I had the opportunity to work with anomaly detection algorithms, and among them, I had the chance to closely explore the Robust Random Cut Forest (RRCF). Interestingly, I discovered that while scikit-learn already has Isolation Forest algorithm, RRCF implementation is still missing. This revelation has sparked a motivating drive within me to advocate for the integration of RRCF.

Although it is plausible that this discussion on this topic might have already been occurred, but I was not able to find anything related to RRCF in the issues section or in [scikit-learn-contrib](https://github.com/scikit-learn-contrib/scikit-learn-contrib) except in [this comment](https://github.com/scikit-learn/scikit-learn/issues/17307#issuecomment-632795440) (where the context is kind of different).

COMMENT:
@betatim I think that we don't have the API to accommodate the streaming part of the algorithm. This is currently out-of-scope. This is probably more in the scope of `river`: https://github.com/online-ml/river

Labels: New Feature, Needs Decision, Needs Decision - Include Feature
Implementation of Robust Random Cut Forest (RRCF) Algorithm

### Describe the workflow you want to enable

Enable users to perform robust anomaly detection using the Robust Random Cut Forest (RRCF) algorithm within the scikit-learn library.

### Describe your proposed solution

## Proposed Solution

I suggest the integration of the Robust Random Cut Forest (RRCF) [[paper](http://proceedings.mlr.press/v48/guha16.pdf)] algorithm into the scikit-learn library. The RRCF algorithm is a natural extension of the Isolation Forest. It presents improved capabilities in handling noisy data, outliers, and stream data scenarios.

The core idea behind RRCF is akin to the Isolation Forest—building binary search trees using random cuts in the input data space. The key distinction lies in the _probability of selecting a cut dimension being proportionate to the dimension's length_. This unique characteristic renders RRCF particularly suitable for scenarios where the Isolation Forest may not perform optimally.

## Implementation

The underlying tree and forest structure of RRCF closely resembles that of the existing iForest, as previously mentioned. The primary difference arises in the computation of anomaly scores, specifically within the `decision_function`.

Additionally, to cater to stream data scenarios, the implementation could (and it should) incorporate methods for efficient insertion and deletion of individual points, as mentioned in the paper.

### Existing Implementations

A pre-existing Python implementation of RRCF can be found at https://github.com/kLabUM/rrcf. This implementation appears to be well-structured and accurate, making it a potential reference for scikit-learn's integration.

I would greatly appreciate your consideration of this proposal. Thank you.

On a side note, please don't hesitate to point out any mistakes/enhancements in the proposal. I'll be glad to assist.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

This past summer, I had the opportunity to work with anomaly detection algorithms, and among them, I had the chance to closely explore the Robust Random Cut Forest (RRCF). Interestingly, I discovered that while scikit-learn already has Isolation Forest algorithm, RRCF implementation is still missing. This revelation has sparked a motivating drive within me to advocate for the integration of RRCF.

Although it is plausible that this discussion on this topic might have already been occurred, but I was not able to find anything related to RRCF in the issues section or in [scikit-learn-contrib](https://github.com/scikit-learn-contrib/scikit-learn-contrib) except in [this comment](https://github.com/scikit-learn/scikit-learn/issues/17307#issuecomment-632795440) (where the context is kind of different).

COMMENT:
Thanks @sudiptoguha for the insights.

Labels: New Feature, Needs Decision, Needs Decision - Include Feature