Jumat, 11 Agustus 2017

Canberra Distance Example

You are given an example of the Canberra distance calculation in this article. My goal is to make it easier for you to understand the method of distance calculation with this method.

Given a dataset as below

Sepal length
Sepal Width
Petal length
Petal Width
5.5
2.3
4
1.3
6.3
3.3
4.7
1.6
5.2
2.7
3.9
1.4
6.1
2.9
4.7
1.4
7.1
3
5.9
2.1
6.5
3
5.9
2.1
7.2
3.6
6.1
2.5
5.8
2.8
5.1
2.4
7.7
2.6
6.9
2.3
5.6
2.8
4.9
2
















Then from the above dataset. Taken a second data.

Sepal length
Sepal Width
Petal length
Petal Width
6.3
3.3
4.7
1.6





Calculate the distance between the second data and all the data contained in the data set above by using the canberra distance method?

Distance calculation with canberra distance can be formulated like this.


Let us calculate them

1. Calculate the distance between the second data and the first data


2. Calculate the distance between the second data and the fifth data



After all data is calculated then got result like following.

Sepal length
Sepal Width
Petal length
Petal Width
Distance
5.5
2.3
4
1.3
13.86645
6.3
3.3
4.7
1.6
15.9
5.2
2.7
3.9
1.4
13.85163
6.1
2.9
4.7
1.4
15.37796
7.1
3
5.9
2.1
18.88571
6.5
3
5.9
2.1
18.19047
7.2
3.6
6.1
2.5
20.49414
5.8
2.8
5.1
2.4
16.91599
7.7
2.6
6.9
2.3
20.83993
5.6
2.8
4.9
2
15.85518

Cosine Distance Example

This article discusses cosine distance example. We will measure distance between data by cosine distance method. About cosine distance theory you can read in my article titled "List Calculation of distance between data points"

Presented the data set as below.

Sepal length
Sepal Width
Petal length
Petal Width
5.5
2.3
4
1.3
6.3
3.3
4.7
1.6
5.2
2.7
3.9
1.4
6.1
2.9
4.7
1.4
7.1
3
5.9
2.1
6.5
3
5.9
2.1
7.2
3.6
6.1
2.5
5.8
2.8
5.1
2.4
7.7
2.6
6.9
2.3
5.6
2.8
4.9
2
















Next we will calculate the distance between the second data with all the data in the table above. For that we take the second data from a table like this.

Sepal length
Sepal Width
Petal length
Petal Width
6.3
3.3
4.7
1.6





Let us calculate distance between two data with all data using cosine distance method using this formula.



1. Calculate second data distance with first data


2. Calculates second data distance with fifth data


After all data is calculated then got result like table below


Sepal length
Sepal Width
Petal length
Petal Width
Distance
5.5
2.3
4
1.3
53.09452
6.3
3.3
4.7
1.6
75.23
5.2
2.7
3.9
1.4
51.49649
6.1
2.9
4.7
1.4
69.60587
7.1
3
5.9
2.1
98.15019
6.5
3
5.9
2.1
89.85717
7.2
3.6
6.1
2.5
107.8565
5.8
2.8
5.1
2.4
72.61512
7.7
2.6
6.9
2.3
117.1933
5.6
2.8
4.9
2
66.87255

Kamis, 10 Agustus 2017

Chebyshev Distance Example

Hello, nice to meet you.

In this article I will give an example of how to calculate the distance by using Chebyshev Distance. About chebysev distance you can learn in my article about"List Calculation of distancebetween data points".

Given the data set as below.

Sepal length
Sepal Width
Petal length
Petal Width
5.5
2.3
4
1.3
6.3
3.3
4.7
1.6
5.2
2.7
3.9
1.4
6.1
2.9
4.7
1.4
7.1
3
5.9
2.1
6.5
3
5.9
2.1
7.2
3.6
6.1
2.5
5.8
2.8
5.1
2.4
7.7
2.6
6.9
2.3
5.6
2.8
4.9
2
















We will measure distance between the fifth data with other data therefore we prepare the fifth data as below.


Sepal length
Sepal Width
Petal length
Petal Width
7.1
3
5.9
2.1





Let us calculate the distance between the fifth data and the other data set using the formula.



1. Calculate the fifth data distance with the first data


2. Calculate the fifth data distance with the second data


So after all the measured data distance obtained results like the table below.


Sepal length
Sepal Width
Petal length
Petal Width
Distance
5.5
2.3
4
1.3
1.9
6.3
3.3
4.7
1.6
1.2
5.2
2.7
3.9
1.4
2
6.1
2.9
4.7
1.4
1.2
7.1
3
5.9
2.1
0
6.5
3
5.9
2.1
0.6
7.2
3.6
6.1
2.5
0.6
5.8
2.8
5.1
2.4
1.3
7.7
2.6
6.9
2.3
1
5.6
2.8
4.9
2
1.5