Problem in function "balanced_accuracy_score" calculation.

### Describe the bug

Hi all I am facing a problem in reproducing the `balanced_accuracy_score` function.

Many resources converges on the equation of balanced accuracy as we can see in the link https://www.statology.org/balanced-accuracy-python-sklearn/. 

By definition it is:


Sensitivity or True Positive Rate = $\Large \frac{TP}{TP + FP}$

Specificity or True Negative Rate = $\Large \frac{TN}{TN + FN}$

Balanced Accuracy = $\Large \frac{Sensitivity + Specificity}{2}$

Simulating results by hand and using the built-in function the answers diverges. 

### Steps/Code to Reproduce

Let's simulate 100 data points where TP = 30, TN = 40, FP = 12 and FN = 18.
Then, we calculate the True Positive and Negative Rate (Sensitivity and Specificity).
Finally, the calculate the result of accuracy and balanced_accuracy.


```python
from sklearn.metrics import balanced_accuracy_score, accuracy_score, confusion_matrix
import numpy as np

tp, tn, fp, fn = 30, 40, 12, 18

sensitivity = tp / (tp + fp) 
specificity = tn / (tn + fn)

acc = (tp + tn) / (tp + tn + fp + fn)
balanced_acc = (sensitivity + specificity) / 2

print("Accuracy:", acc) #  # 0.7 all good here 0.7 as expected from true values
print("Balanced Accuracy:", balanced_acc) # 0.70197

# Now with built-in functions, we simulate 100 values that represent the same tp, tn, fp, fn:

y_true = np.repeat([1, 0, 0, 1], repeats=[30, 40, 12, 18])
y_pred = np.repeat([1, 0, 1, 0], repeats=[30, 40, 12, 18])

acc2 = accuracy_score(y_true, y_pred)
balanced_acc2 = balanced_accuracy_score(y_true, y_pred)

print("Accuracy:", acc2) #  0.7 here, it's fine as expected
print("Balanced Accuracy:", balanced_acc2) # 0.69711 value here diverges
```

If we extract the TP, TN, FP, FN from the simulated predictions, we have the right values:

```python
tn, fp, fn, tp = confusion_matrix(y_true, y_pred).ravel()

sensitivity = tp / (tp + fp) 
specificity = tn / (tn + fn)
balanced_acc = (sensitivity + specificity) / 2

print("Balanced Accuracy:", balanced_acc) # 0.70197 - We got the right value as expected, sklearn gave us a wrong answer
```

Solution:

Sklearn have classes in **columns** as we can see in the code for the same example:

```python
confusion_matrix(y_true, y_pred)
# array([[40, 12],
#        [18, 30]])
```

If we change the code in the `balanced_accuracy_score` function, found at `sklearn/metrics/_classification.py` 

```python
# as is
per_class = np.diag(C) / C.sum(axis=1)

# fixed
per_class = np.diag(C) / C.sum(axis=0)
```

The result will be as expected!

### Expected Results

Expected value for this example is `0.70197`

### Actual Results

Actual value got is `0.69711`

### Versions

```shell
System:
    python: 3.11.3 | packaged by conda-forge | (main, Apr  6 2023, 08:58:31) [Clang 14.0.6 ]
executable: /opt/miniconda3/bin/python
   machine: macOS-13.5.1-arm64-arm-64bit

Python dependencies:
      sklearn: 1.3.0
          pip: 23.1.2
   setuptools: 67.7.2
        numpy: 1.25.2
        scipy: 1.11.2
       Cython: None
       pandas: 2.0.3
   matplotlib: 3.7.2
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: libomp
       filepath: /opt/miniconda3/lib/python3.11/site-packages/sklearn/.dylibs/libomp.dylib
        version: None
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /opt/miniconda3/lib/python3.11/site-packages/numpy/.dylibs/libopenblas64_.0.dylib
        version: 0.3.23.dev
threading_layer: pthreads
   architecture: armv8
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /opt/miniconda3/lib/python3.11/site-packages/scipy/.dylibs/libopenblas.0.dylib
        version: 0.3.21.dev
threading_layer: pthreads
   architecture: armv8
    num_threads: 8
```

COMMENT:
You made a mistake in the definition of the sensitivity and specificity: https://en.wikipedia.org/wiki/Sensitivity_and_specificity

```python
sensitivity = tp / (tp + fn)
specificity = tn / (tn + fp)
```

In this case, you have the balanced accuracy equal to:

```
0.6971153846153846
``

That is the reported values by the scikit-learn implementation.

Labels: Bug, Needs Triage