Error in ML

In Machine Learning one of the main tasks is to model the data and predict the output using various Classification and Regression Algorithms. But since there are so many Algorithms, it is really difficult to choose the one for predicting the final data. So we need to compare our models and choose the one which best suits the task at hand. Please note, accuracy need not always be the best metric to choose a model. More about this in later tutorials. 

Using the sklearn library we can find out the scores of our ML Model and thus choose the algorithm with a higher score to predict our output. Another good way is to calculate errors such as mean absolute error and mean squared error and try to minimize them to better our models. 

Mean Absolute Error(MAE): It is the mean of all absolute error  


Mean Squared Error (MSE) It is the mean of the square of all errors. 

Type 1 and Type 2 error

Type 1 error: It occurs when the model incorrectly predicts a positive instance but the actual instance is negative. This is also known as a false positive. Type 1 Errors affect the precision of a model which measures the accuracy of positive predictions.

Type 2 error: This occurs when the model fails to predict a positive instance even though it is actually positive. This is also known as a false negative. Type 2 Errors impact the recall of a model which measures how well the model identifies all actual positive cases.

Example: A diagnostic test is used to detect a particular disease in patients.

  • Type 1 Error (False Positive): This occurs when the test predicts a patient has the disease (positive result) but the patient is actually healthy (negative case).
  • Type 2 Error (False Negative): This occurs when the test predicts the patient is healthy (negative result) but the patient actually has the disease (positive case).