snowflake.ml.modeling.metrics.mean_absolute_percentage_error¶
- snowflake.ml.modeling.metrics.mean_absolute_percentage_error(*, df: DataFrame, y_true_col_names: Union[str, List[str]], y_pred_col_names: Union[str, List[str]], sample_weight_col_name: Optional[str] = None, multioutput: Union[str, _SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]] = 'uniform_average') Union[float, ndarray[Any, dtype[float64]]] ¶
Mean absolute percentage error (MAPE) regression loss.
Note here that the output is not a percentage in the range [0, 100] and a value of 100 does not mean 100% but 1e2. Furthermore, the output can be arbitrarily high when y_true is small (which is specific to the metric) or when abs(y_true - y_pred) is large (which is common for most regression metrics).
- Args:
- df: snowpark.DataFrame
Input dataframe.
- y_true_col_names: string or list of strings
Column name(s) representing actual values.
- y_pred_col_names: string or list of strings
Column name(s) representing predicted values.
- sample_weight_col_name: string, default=None
Column name representing sample weights.
- multioutput: {‘raw_values’, ‘uniform_average’} or array-like of shape (n_outputs,), default=’uniform_average’
Defines aggregating of multiple output values. Array-like value defines weights used to average errors. ‘raw_values’:
Returns a full set of errors in case of multioutput input.
- ‘uniform_average’:
Errors of all outputs are averaged with uniform weight.
- Returns:
- loss: float or ndarray of floats
If multioutput is ‘raw_values’, then mean absolute percentage error is returned for each output separately. If multioutput is ‘uniform_average’ or an ndarray of weights, then the weighted average of all output errors is returned.
MAPE output is non-negative floating point. The best value is 0.0. But note that bad predictions can lead to arbitrarily large MAPE values, especially if some y_true values are very close to zero. Note that we return a large value instead of inf when y_true is zero.