Skip to main content

Confusion metrix.

 when we are thinking about the evaluation of classification machine learning problem, confusion Metrix comes in top. as the name describes confusion, really very confusing to understand this scenario. but it is not too hard to understand if you apply some logic behind this concept.

so generally, this concept is used to understand how much record we have correctly predicted and incorrectly. in classification problem we have values in categories might be 2 or multiple categories.

binary classification Metrix.

we have 0 for negative and 1 for positive in targeted variable. and let's consider we have total 50 target record and out of 50 we have 30 positive and 20 negative, please keep in mind.


now, consider we have a machine learning model and result for output is 35 positive and 15 negative. but we are unable to decide which one predicted correctly and which one in incorrect. 

so, let's understand some concept in confusion metix.

0--negative

1--positive.


TP is called true positive means model predicted positive that is really positive in real data.

TN is called rue negative means model predicted negative that is really negative in real data.

FP is called false positive means model predicted positive that is really negative in real data.

FN is called false negative means model predicted negative that is really positive in real data.

so according to above terminology, our model has prediction of.

TP=25

TN=10

FP=10

FN=5

our concept is clear till now, now understand the rule and policy here to calculate the values in our datasets.

precision=TP/TP+FP--So the precision is calculated as the percentage of total positive result by total positive prediction by our model.

as, per above examples we have TP=25 and FP=10, so precision =25/25+10=25/35=0.714

recall=TP/TP+FN--recall

as, per above examples we have TP=25 and Fn=5, so precision =25/25+10=25/30=0.714=0.83333


now let's understand about the type 1 error and type 2 error.

FP= false positive is called type 1 error

FN= false negative is called type 2 error.


what is specificity.

the specificity is calculated as the number of correct negative prediction divided by total number of negatives. TN\TN+FP

this is also called true negative rate. the best specificity is 1 and worst is 0.


what is accuracy:

accuracy in confusion Metrix is calculated as total number of correct predictions divided by total number of records. 

TP+TN/TP+TN+FN+FP


what is f measure: The formula for the standard F1-score is the harmonic mean of the precision and recall. A perfect model has an F-score of 1.

f measure is calculated as 2*recall*precision/recall+precision
















Comments

Popular posts from this blog

Feature engineering

 we all know machine learning model do not understand text data, so we need to transform the text data to number. i.e we need to transform the raw data to well prepared data to implement the machine learning model for prediction. the process to convert the raw data to make well prepared data is called feature engineering.

Evaluation metrics for Regression

 Welcome to this post, you fall in very good place and interesting part of machine learning implementation. Evaluation- how we feel with this word, definitely we are going to examine something, i .e out machine learning model. feels very responsible state of mind- going to check and correcting our model. when we are discussing about the machine learning, it divided into 3 parts supervised, unsupervised and reinforcement. we are not going to discuss in detail about this you can use other Resorces to learn or our other post. supervised machine learning is of two types regression and classification. we will learn to evaluate these two separately in this post. Evaluation metrics for Regression: when we have made the regression model where our target value is continuous, we use following method to evaluate the model: MAE: (mean absolute error) MSE: (mean square error) RMSE: (root mean square error) R squared error Adjusted R squared. before we discussed about these techniques for evalua...

Decision Tree

\we are discussion about decision tree which falls under supervised learning algorithm and used for classification and regression both. I Will try to cover to each and every topic regarding this algorithm and write python code to implement the same. before falling to discussion, we need understand this popular technique of machine learning. now the definition is: this tree like structure and a kind of predictive modeling approach. it has tree like structure upside down use to represent decision for decision making. this can handle high dimensional data with high accuracy. this tree also used to predict house price, car value and categorical data as well. the decisoion tree represent root node,terminal node,decision node and branches. sandhyakrishnana decion tree medium