Course Name: EPAT-Introduction to Machine Learning for Trading, Section No: 4,Unit No: 1, Unit- linear regression
In Mean squared error, what is the logic of using %2f%?also in course it is stated that,larger the numebr,larger the error..
in this example.the mean squared error the output value has arrived 2548 like something.so it is big error or less error?
how much larger value is larger error or less error ?
Hello Shrirang,
The right use is %.2f. Thanks for pointing this out and the notebook will be updated accordingly. So, the modified print statement would be
print('Mean squared error: %.2f' %
np.mean((regr.predict(diabetes_X_test)-diabetes_y_test)**2))
Here %.2f is a string formatting specifier that indicates the format of the value that will be inserted in its place. Here, it indicates that the value that will be printed is a floating-point number with 2 decimal places.
The % symbol in this code after the statement in quotes is used to format the output of the print() statement. The % operator in python for strings is used for something called string substitution.
In the given example, the value of
np.mean((regr.predict(diabetes_X_test)-diabetes_y_test)**2)
will be substituted in the string 'Mean squared error: %.2f' in place of %.
This results in an output of Mean squared error: 2548.07. As you can see, the floating-point number has 2 decimal places since we used %.2f
Regarding your second question, a larger value of mean squared error indicates a larger error between the predicted and true values. In other words, a higher MSE indicates that the predictions are further away from the actual values. However, it is important to note that the interpretation of "large" or "small" depends on the context of the problem being solved. For example, in some applications, an MSE of 100 may be considered small, while in others, an MSE of 0.01 may be considered large.
The magnitude of the error depends on the scale of the data being measured. For example, an error of 10 on data with a scale of 1-100 would be considered small, while an error of 10 on data with a scale of 1000-1100 would be considered large. Therefore, what is considered a large or small error depends on the context and scale of the data being measured.
I hope this helps!
Hello Shrirang,
The notebook has been updated. "%2f" has been changed to "%.2f"
Thanks for pointing this out!