 5

# Multioutput not supported in max_error

Package:
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>`. """``````
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

## 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)
```