 5

# Multioutput not supported in max_error

Exception Class:
ValueError

## Raise code

``````"""
>>> y_true = [3, 2, 7, 1]
>>> y_pred = [4, 2, 7, 1]
>>> max_error(y_true, y_pred)
1
"""
y_type, y_true, y_pred, _ = _check_reg_targets(y_true, y_pred, None)
if y_type == 'continuous-multioutput':
raise ValueError("Multioutput not supported in max_error")
return np.max(np.abs(y_true - y_pred))

def mean_tweedie_deviance(y_true, y_pred, *, sample_weight=None, power=0):
"""Mean Tweedie deviance regression loss.

Read more in the :ref:`User Guide <mean_tweedie_deviance>`. """``````
😲 Agile task management is now easier than calling a taxi. #Tracklify
🙏 Scream for help to Ukraine
Today, 2nd July 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too! We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.

## Ways to fix 2 ## Summary:

This exception is thrown when the max_error function is called from sklearn.metrics. The function takes in 2 parameters: y_true and y_pred. Both of these functions are array-like. The method returns a positive floating-point value. The exception can happen if y_true has a second dimension of size greater than 1. This is because it then categorizes it as continuous-multipout and it doesn't support that. If your array is more than one dimension then the best way to pass it into the function without getting any exceptions is by using np.reshape and converting it to a 1-dimensional array.

## Code to Reproduce the Error (Wrong):

```from sklearn.metrics import max_error
import numpy as np
y_true = np.array([[3, 2], [7, 1]])
y_pred = np.array([[4, 2], [7, 1]])
max_error(y_true, y_pred)
```

## Error Message:

```ValueError                                Traceback (most recent call last)
<ipython-input-16-687d2301de8a> in <module>()
3 y_true = np.array([[3, 2], [7, 1]])
4 y_pred = np.array([[4, 2], [7, 1]])
----> 5 max_error(y_true, y_pred)

/usr/local/lib/python3.7/dist-packages/sklearn/metrics/_regression.py in max_error(y_true, y_pred)
653     y_type, y_true, y_pred, _ = _check_reg_targets(y_true, y_pred, None)
654     if y_type == 'continuous-multioutput':
--> 655         raise ValueError("Multioutput not supported in max_error")
656     return np.max(np.abs(y_true - y_pred))
657

ValueError: Multioutput not supported in max_error
```

## Working Version (Right):

```from sklearn.metrics import max_error
import numpy as np
y_true = np.array([[3, 2], [7, 1]])
y_pred = np.array([[4, 2], [7, 1]])
y_true = np.reshape(y_true, (4,1))
y_pred = np.reshape(y_pred, (4,1))
max_error(y_true, y_pred)
```