when we use sklearn,
from sklearn.metrics import mean_squared_error
why we can use only this way to caluate mse?
import sklearn
sklearn.metrics.mean_squared_error
why this way can not? and The compiler will report an error(module sklearn has no attribute metrics).
It is possible in both the ways to find mean_squared_error. For you, the compiler has reported an error because you havenot specified any attributes. I hope below example helps you
from sklearn.metrics import mean_squared_error
Y_true = [1,1,2,2,4] # Y_true = Y (original values)
Y_pred = [0.6,1.29,1.99,2.69,3.4] # Y_pred = Y'
# Calculation of Mean Squared Error (MSE)
mean_squared_error(Y_true,Y_pred)
or
import sklearn
# Given values
Y_true = [1,1,2,2,4] # Y_true = Y (original values)
Y_pred = [0.6,1.29,1.99,2.69,3.4] # Y_pred = Y'
# Calculation of Mean Squared Error (MSE)
sklearn.metrics.mean_squared_error(Y_true,Y_pred)
You can refer my Example by clicking this link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With