welcome back in this video I will discuss how to calculate euclidean Manhattan minkowski supremum distance also I will discuss how to find the cosine similarity between two data points in this case we have been given five data points over here that is X1 X2 X3 X4 and X5 we need to find the distance between these data points with respect to a new data point over here that is X is equal into 1. 4 comma 1. 6 over here now we will try to find the first distance measure that is the euclidean distance if you want to find the euclidean distance between two data points let us say that P1 and P2 which is denoted by X1 comma y1 and the P2 is denoted by X2 comma Y2 the distance formula is square root of x 2 minus x 1 bracket square plus Y 2 minus y 1 bracket Square over here and this is the new data point this is the first editor point I want to find the distance between this new data point with respect to First Data point over here just to make sure that you don't get confused I have replaced that X1 X2 X3 to 1 2 3 4 5 over here now this is the first data point uh you can say this one as X1 here and this one you can say that y1 and this will become X2 and this will become Y2 over here so according to this particular formula square root of x 2 minus x 1 bracket Square x 2 is what here 1.
4 x 1 is 1. 5 so that is 1. 4 minus 1.
5 bracket square plus Y 2 that is 1. 6 minus 1. 7 bracket Square so every time this X2 by 2 will remain same but this x 1 y 1 will change here so that is how we need to find the distance now if you put those particular values in this equation as I said earlier 1.
4 minus 1. 5 bracket square plus 1. 6 minus 1.
7 bracket Square you will get this one similarly you will find all the distance over here that is the distance between this new data point with respect to this point five points over here coming back to the next distance measure that is a Manhattan distance if you want to find the distance between this P1 and P2 you need to use this particular formula the formula is cardinality of X2 minus X1 plus cardinality of Y2 minus y1 over here again the same thing this is X2 Y2 and this one is X1 y1 in the next case it will become x 1 y 1 and so on so the first one will look something like this one X2 is 1. 4 and X1 is 1. 5 here Y2 is 1.
6 and y1 is 1. 7 over here now if you find this solve this equation you will it will get 1. 4 minus 1.
5 is minus 0. 1 the cardinality is plus 0. 1 here similarly 1.
6 minus 1. 7 is minus 0. 1 again if you take the cardinality it will become plus point one if I add it I will get plus 0.
2 over here similarly you need to find out the different measures over here that is the distance between new data points with respect to 2 3 4 and 5 over here coming back to the next distance measure that is minkowski distance if you want to find the distance between P1 and P2 again we need to use this equation if you look at this equation it is almost similar to euclidean distance formula in euclidean distance we used to take the square root over here in this case we have taken H again in euclidic distance we write here square that is the X2 minus x 1 bracket Square we used to write in this case we have written power H over here based on the value of this particular H this particular formula will become different over here so in this case I have considered H is equivalent to again 2 if anything other than is other than 2 is present you need to get the different formula over here if I take H is equivalent to 2 the formula looks something like this which is exactly similar to our euclidean distance so the distance over here is so and so coming back to the next one that is the supremum distance if you want to find the distance between two data points with respect to two supremum distance formula the formula looks something like this that is a maximum of cardinality of x 2 minus x 1 comma cardinality of Y2 minus y1 over here again the same thing X2 is here Y2 is here X1 is over here and y1 is over here so if I put that particular thing this is what we will get point one here here also we will get point one the maximum is 0. 1 here but in the second case in this case we will get the 0. 6 here we will get 0.
3 the maximum is 0. 6 so that is what the answer over here coming back to the last distance measure that is cosine similarity if you want to find the distance between two points that is a and b you can write the formula something like this one summation of a i b i divided by square root of summation of a square multiplied by square root of summation of b i Square here now the numerator looks something like this in the first case this is you can say that this point you can say that a here and this particular point you can say that b here so summation of a i b i summation of a i b a is nothing but what 1. 5 multiplied by 1.
4 plus 1. 7 multiplied by 1. 6 so that is what I have written at the numerator side denominator is summation of a i square a is nothing but what this one that is the summation square root of 1.
5 bracket square plus 1. 7 bracket Square multiplied by that is in between multiply we have there is a bi Square summation of square root of summation of b s square square root of summation of bi that is 1. 5 1.
4 bracket square plus 1.