circuit_knitting.utils.metrics.MAPE

MAPE(target, obs)[source]

Compute the Mean Absolute Percentage Error (MAPE).

The MAPE is a scaled metric in the range [0, 100] defining the percentage difference between two vectors via: $ sum_i frac{x_i - y_i}{x_i} $.

Deprecated since version 0.7.0: The function circuit_knitting.utils.metrics.MAPE() is deprecated as of circuit-knitting-toolbox 0.7.0. It will be removed no sooner than CKT v0.8.0.

Example: >>> MAPE(np.array([0.1, 0.1, 0.3, 0.5]), np.array([0.25, 0.25, 0.25, 0.25])) 91.66666666666659

Parameters:
  • target – The target feature vector

  • obs – The actually observed feature vector

Returns:

The computed MAPE

Raises:
  • Exception – The target is not a dict

  • Exception – The target and obs are not numpy arrays

  • Exception – The target is not a numpy array and the obs are not a dict