Mean Squared Error in Numpy?

前端 未结 6 1485
忘掉有多难
忘掉有多难 2020-12-13 12:01

Is there a method in numpy for calculating the Mean Squared Error between two matrices?

I\'ve tried searching but found none. Is it under a different name?

I

6条回答
  •  执念已碎
    2020-12-13 12:22

    This isn't part of numpy, but it will work with numpy.ndarray objects. A numpy.matrix can be converted to a numpy.ndarray and a numpy.ndarray can be converted to a numpy.matrix.

    from sklearn.metrics import mean_squared_error
    mse = mean_squared_error(A, B)
    

    See Scikit Learn mean_squared_error for documentation on how to control axis.

提交回复
热议问题