`pairwise_distances` is inconsistent with `scipy.spatial.distance` when using `metric="matching"`

### Describe the bug

Although the metric `matching` is already removed from the documentation, `pairwise_distances` function still allows its usage. When used, the input arrays are converted into boolean. This brings inconsistency with the counterpart function `cdist` and `pdist` from `scipy.spatial.distance` (note that `scipy.spatial.distance.matching` [has been completely removed](https://github.com/scipy/scipy/commit/b74c192aab55422d52589cf0023d9b3bfb5d136b#diff-31574bfaee9d89d5e1b6908cd8644889eaf28c4bca240f6e64561dfc7c5995c1L1357) since v1.10.0). In scipy's `cdist` and `pdist`, the metric `matching` is [considered a synonym](https://github.com/scipy/scipy/blob/v1.10.0/scipy/spatial/distance.py#L1829) for `hamming`, which allows non-boolean inputs. 

To address this issue, I can propose 2 solutions:
1. Disallow `matching` usage as a metric. This fix will remove `matching` from metrics allowed on `pairwise.py` and `sklearn.neighbors._base.py`.
2. Allow non-boolean inputs when using `matching` as a metric. This fix will keep it consistent to scipy's implementation.

Once the solution is decided, I can make a PR for it.

### Steps/Code to Reproduce

```python
import numpy as np
from sklearn.metrics import pairwise_distances
from scipy.spatial.distance import cdist

x = np.array([[1, 0, -1, 1, 0, -1]])
y = np.array([[0, -1, 1, 1, 0, -1]])
print('pairwise_distances: ', pairwise_distances(x, y, metric='matching'))
print('scipy cdist: ', cdist(x, y, metric='matching'))
```

### Expected Results

```
pairwise_distances:  [[0.5]]
scipy cdist:  [[0.5]]
```

### Actual Results

```
/usr/local/lib/python3.11/site-packages/sklearn/metrics/pairwise.py:2025: DataConversionWarning: Data was converted to boolean for metric matching
  warnings.warn(msg, DataConversionWarning)
pairwise_distances:  [[0.33333333]]
scipy cdist:  [[0.5]]
```

### Versions

```shell
System:
    python: 3.11.1 (main, Jan 23 2023, 21:39:49) [GCC 10.2.1 20210110]
executable: /usr/local/bin/python3
   machine: Linux-5.15.49-linuxkit-aarch64-with-glibc2.31

Python dependencies:
      sklearn: 1.2.1
          pip: 22.3.1
   setuptools: 65.5.1
        numpy: 1.24.1
        scipy: 1.10.0
       Cython: None
       pandas: None
   matplotlib: None
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: libgomp
       filepath: /usr/local/lib/python3.11/site-packages/scikit_learn.libs/libgomp-d22c30c5.so.1.0.0
        version: None
    num_threads: 5

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /usr/local/lib/python3.11/site-packages/numpy.libs/libopenblas64_p-r0-cecebdce.3.21.so
        version: 0.3.21
threading_layer: pthreads
   architecture: armv8
    num_threads: 5

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /usr/local/lib/python3.11/site-packages/scipy.libs/libopenblasp-r0-dff490c2.3.18.so
        version: 0.3.18
threading_layer: pthreads
   architecture: armv8
    num_threads: 5
```

COMMENT:
Hello @magnusbarata!

When I Ctrl+F "matching" on the [parwise.py file](https://github.com/scikit-learn/scikit-learn/blob/5b23a2d77b28a4d4fbf07d60cd0932769110a532/sklearn/metrics/pairwise.py#L2047) I found out that it was inside the `PAIRWISE_BOOLEAN_FUNCTIONS` list and decided to run your code for these "boolean" metrics as well (also that is related to the warning you showed so it made sense to take a look).

<details>

  ```python
  from sklearn import __version__
  print(__version__)
  >>> 1.2.0
  
  import numpy as np
  from sklearn.metrics import pairwise_distances
  from scipy.spatial.distance import cdist
  from sklearn.metrics.pairwise import PAIRWISE_BOOLEAN_FUNCTIONS
  
  X = np.array([[1, 0, -1, 1, 0, -1]])
  Y = np.array([[0, -1, 1, 1, 0, -1]])
  ```
</details>

```python
for metric in PAIRWISE_BOOLEAN_FUNCTIONS:
    if not (pairwise_distances(x, y, metric=metric) == cdist(x, y, metric=metric)):
        print(metric, end=" ")
>>> ...\pairwise.py:2025: DataConversionWarning: Data was converted to boolean for metric ...
>>> warnings.warn(msg, DataConversionWarning)
>>> jaccard matching 
```

I got the same bug. This time for "jaccard" also! So, maybe, it was something related to this conversion. Indeed it is.

I tried to follow the logic of the [`pairwise_distances` function](https://github.com/scikit-learn/scikit-learn/blob/5b23a2d77b28a4d4fbf07d60cd0932769110a532/sklearn/metrics/pairwise.py#L1881) and ended up this minimal code:

```python
metric = "matching"
kwds = {}

from functools import partial
from sklearn.metrics.pairwise import check_pairwise_arrays, _precompute_metric_params, _parallel_pairwise

dtype = bool if metric in PAIRWISE_BOOLEAN_FUNCTIONS else None

if dtype == bool and (X.dtype != bool or (Y is not None and Y.dtype != bool)):
    msg = "Data was converted to boolean for metric %s" % metric
    print(msg)

X, Y = check_pairwise_arrays(
    X, Y, dtype=dtype
)

# precompute data-derived metric params
params = _precompute_metric_params(X, Y, metric=metric, **kwds)
kwds.update(**params)

func = partial(cdist, metric=metric, **kwds)

_parallel_pairwise(X, Y, func, 1, **kwds)
>>> Data was converted to boolean for metric matching
>>> array([[0.33333333]])
```

We are getting the same result from the `pairwise_distances` function, but when I look at the transformed `X` and `Y`, we now have this:

```python
print(X, Y, sep="\n")
>>> [[ True False  True  True False  True]]
>>> [[False  True  True  True False  True]]
```

Where we once had an `-1, 1` pair (third component), now we have `True, True` (they are both non-zero) and they match. `metric="jaccard"` seems to be affected by this as well, but others `PAIRWISE_BOOLEAN_FUNCTIONS`' metrics don't. I don't know why without further looking into their logic.

Looking at the git blame, apparently, the transformation to boolean was introduced by #6932 to fix #4523. It made sense in that context because it looked like a binary scenario.

In my opinion, we should not treat this as a bug, mainly because of the warning we already have. If you want to use the "matching" distance for non-boolean arrays, you can try `metric="hamming"`, and it will do what you want:

```python
x = np.array([[1, 0, -1, 1, 0, -1]])
y = np.array([[0, -1, 1, 1, 0, -1]])

print(pairwise_distances(x, y, metric="hamming"))
>>> [[0.5]]
```

___

Edit: I wrote my answer without having read your description, just your code. I saw now that you already knew that the problem was in the transformation to bool and that you know about hamming. My bad (but I'll leave it here because of some extra information I found).
My concern with your first solution is to generate regressions such as messing up again the issue that introduced this transformation or removing this metric from `NearestNeighbors`. The second one looks better, but we already have hamming, maybe we want matching to be the boolean version of it... I don't know heheh The core contributors will be able to evaluate it better! :D

Labels: Bug