circuit_knitting.utils.metrics.MSE

MSE(target, obs)[source]

Compute the Mean Squared Error (MSE).

The MSE is a common metric in fields such as deep learning and is used to measure the squared distance between two vectors via: $sum_i (x_i - y_i)^2$.

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

Example: >>> MSE(np.array([0.1, 0.1, 0.3, 0.5]), np.array([0.25, 0.25, 0.25, 0.25])) 0.0275

Parameters:
  • target – The target feature vector

  • obs – The actually observed feature vector

Returns:

The computed MSE

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