Clustering

Learning Vector Quantization.*;

LVQ Example 1

Because of the nature of the distance measuring formula used in this code, you can see that any threshold value below 1.0 will cause a threshold to be created for each input vector. Increasing the threshold value increases the algorithm's capacity to generalize. In other words: The larger the threshold value, the more lenient the algorithm's discrimination becomes. The lower the threshold value, the more strict it becomes.

 

Example Results 1

With a threshold value of 2.0, three clusters are created:

 

Pattern 0 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Pattern 1 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Cluster 0 Pattern[1][0 = 1, Member_ID = 1
Cluster 0 Pattern[1][1 = 0, Member_ID = 1
Pattern 2 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Cluster 0 Pattern[1][0 = 1, Member_ID = 1
Cluster 0 Pattern[1][1 = 0, Member_ID = 1
Cluster 0 Pattern[2][0 = 0, Member_ID = 2
Cluster 0 Pattern[2][1 = 1, Member_ID = 2
Pattern 3 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Cluster 0 Pattern[1][0 = 1, Member_ID = 1
Cluster 0 Pattern[1][1 = 0, Member_ID = 1
Cluster 0 Pattern[2][0 = 0, Member_ID = 2
Cluster 0 Pattern[2][1 = 1, Member_ID = 2
Cluster 0 Pattern[3][0 = 1, Member_ID = 3
Cluster 0 Pattern[3][1 = 1, Member_ID = 3

Creating NEW cluster number: 1

Pattern 4 assigned to cluster 1
Cluster 1 Pattern[4][0 = 0, Member_ID = 4
Cluster 1 Pattern[4][1 = 3, Member_ID = 4
Pattern 5 assigned to cluster 1
Cluster 1 Pattern[4][0 = 0, Member_ID = 4
Cluster 1 Pattern[4][1 = 3, Member_ID = 4
Cluster 1 Pattern[5][0 = 1, Member_ID = 5
Cluster 1 Pattern[5][1 = 3, Member_ID = 5
Pattern 6 assigned to cluster 1
Cluster 1 Pattern[4][0 = 0, Member_ID = 4
Cluster 1 Pattern[4][1 = 3, Member_ID = 4
Cluster 1 Pattern[5][0 = 1, Member_ID = 5
Cluster 1 Pattern[5][1 = 3, Member_ID = 5
Cluster 1 Pattern[6][0 = 0, Member_ID = 6
Cluster 1 Pattern[6][1 = 4, Member_ID = 6
Pattern 7 assigned to cluster 1
Cluster 1 Pattern[4][0 = 0, Member_ID = 4
Cluster 1 Pattern[4][1 = 3, Member_ID = 4
Cluster 1 Pattern[5][0 = 1, Member_ID = 5
Cluster 1 Pattern[5][1 = 3, Member_ID = 5
Cluster 1 Pattern[6][0 = 0, Member_ID = 6
Cluster 1 Pattern[6][1 = 4, Member_ID = 6
Cluster 1 Pattern[7][0 = 1, Member_ID = 7
Cluster 1 Pattern[7][1 = 4, Member_ID = 7

Creating NEW cluster number: 2

Pattern 8 assigned to cluster 2
Cluster 2 Pattern[8][0 = 4, Member_ID = 8
Cluster 2 Pattern[8][1 = 0, Member_ID = 8
Pattern 9 assigned to cluster 2
Cluster 2 Pattern[8][0 = 4, Member_ID = 8
Cluster 2 Pattern[8][1 = 0, Member_ID = 8
Cluster 2 Pattern[9][0 = 5, Member_ID = 9
Cluster 2 Pattern[9][1 = 0, Member_ID = 9
Pattern 10 assigned to cluster 2
Cluster 2 Pattern[8][0 = 4, Member_ID = 8
Cluster 2 Pattern[8][1 = 0, Member_ID = 8
Cluster 2 Pattern[9][0 = 5, Member_ID = 9
Cluster 2 Pattern[9][1 = 0, Member_ID = 9
Cluster 2 Pattern[10][0 = 4, Member_ID = 10
Cluster 2 Pattern[10][1 = 1, Member_ID = 10
Pattern 11 assigned to cluster 2
Cluster 2 Pattern[8][0 = 4, Member_ID = 8
Cluster 2 Pattern[8][1 = 0, Member_ID = 8
Cluster 2 Pattern[9][0 = 5, Member_ID = 9
Cluster 2 Pattern[9][1 = 0, Member_ID = 9
Cluster 2 Pattern[10][0 = 4, Member_ID = 10
Cluster 2 Pattern[10][1 = 1, Member_ID = 10
Cluster 2 Pattern[11][0 = 5, Member_ID = 11
Cluster 2 Pattern[11][1 = 1, Member_ID = 11

Cluster Centers:
	CLUSTER 0 ==>[0.5, 0.5]

	CLUSTER 1 ==>[0.5, 3.5]

	CLUSTER 2 ==>[4.5, 0.5]

 

Example Results 2

With a threshold value of 3.5, two clusters are created:

 

Pattern 0 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Pattern 1 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Cluster 0 Pattern[1][0 = 1, Member_ID = 1
Cluster 0 Pattern[1][1 = 0, Member_ID = 1
Pattern 2 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Cluster 0 Pattern[1][0 = 1, Member_ID = 1
Cluster 0 Pattern[1][1 = 0, Member_ID = 1
Cluster 0 Pattern[2][0 = 0, Member_ID = 2
Cluster 0 Pattern[2][1 = 1, Member_ID = 2
Pattern 3 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Cluster 0 Pattern[1][0 = 1, Member_ID = 1
Cluster 0 Pattern[1][1 = 0, Member_ID = 1
Cluster 0 Pattern[2][0 = 0, Member_ID = 2
Cluster 0 Pattern[2][1 = 1, Member_ID = 2
Cluster 0 Pattern[3][0 = 1, Member_ID = 3
Cluster 0 Pattern[3][1 = 1, Member_ID = 3
Pattern 4 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Cluster 0 Pattern[1][0 = 1, Member_ID = 1
Cluster 0 Pattern[1][1 = 0, Member_ID = 1
Cluster 0 Pattern[2][0 = 0, Member_ID = 2
Cluster 0 Pattern[2][1 = 1, Member_ID = 2
Cluster 0 Pattern[3][0 = 1, Member_ID = 3
Cluster 0 Pattern[3][1 = 1, Member_ID = 3
Cluster 0 Pattern[4][0 = 0, Member_ID = 4
Cluster 0 Pattern[4][1 = 3, Member_ID = 4
Pattern 5 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Cluster 0 Pattern[1][0 = 1, Member_ID = 1
Cluster 0 Pattern[1][1 = 0, Member_ID = 1
Cluster 0 Pattern[2][0 = 0, Member_ID = 2
Cluster 0 Pattern[2][1 = 1, Member_ID = 2
Cluster 0 Pattern[3][0 = 1, Member_ID = 3
Cluster 0 Pattern[3][1 = 1, Member_ID = 3
Cluster 0 Pattern[4][0 = 0, Member_ID = 4
Cluster 0 Pattern[4][1 = 3, Member_ID = 4
Cluster 0 Pattern[5][0 = 1, Member_ID = 5
Cluster 0 Pattern[5][1 = 3, Member_ID = 5
Pattern 6 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Cluster 0 Pattern[1][0 = 1, Member_ID = 1
Cluster 0 Pattern[1][1 = 0, Member_ID = 1
Cluster 0 Pattern[2][0 = 0, Member_ID = 2
Cluster 0 Pattern[2][1 = 1, Member_ID = 2
Cluster 0 Pattern[3][0 = 1, Member_ID = 3
Cluster 0 Pattern[3][1 = 1, Member_ID = 3
Cluster 0 Pattern[4][0 = 0, Member_ID = 4
Cluster 0 Pattern[4][1 = 3, Member_ID = 4
Cluster 0 Pattern[5][0 = 1, Member_ID = 5
Cluster 0 Pattern[5][1 = 3, Member_ID = 5
Cluster 0 Pattern[6][0 = 0, Member_ID = 6
Cluster 0 Pattern[6][1 = 4, Member_ID = 6
Pattern 7 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Cluster 0 Pattern[1][0 = 1, Member_ID = 1
Cluster 0 Pattern[1][1 = 0, Member_ID = 1
Cluster 0 Pattern[2][0 = 0, Member_ID = 2
Cluster 0 Pattern[2][1 = 1, Member_ID = 2
Cluster 0 Pattern[3][0 = 1, Member_ID = 3
Cluster 0 Pattern[3][1 = 1, Member_ID = 3
Cluster 0 Pattern[4][0 = 0, Member_ID = 4
Cluster 0 Pattern[4][1 = 3, Member_ID = 4
Cluster 0 Pattern[5][0 = 1, Member_ID = 5
Cluster 0 Pattern[5][1 = 3, Member_ID = 5
Cluster 0 Pattern[6][0 = 0, Member_ID = 6
Cluster 0 Pattern[6][1 = 4, Member_ID = 6
Cluster 0 Pattern[7][0 = 1, Member_ID = 7
Cluster 0 Pattern[7][1 = 4, Member_ID = 7

Creating NEW cluster number: 1

Pattern 8 assigned to cluster 1
Cluster 1 Pattern[8][0 = 4, Member_ID = 8
Cluster 1 Pattern[8][1 = 0, Member_ID = 8
Pattern 9 assigned to cluster 1
Cluster 1 Pattern[8][0 = 4, Member_ID = 8
Cluster 1 Pattern[8][1 = 0, Member_ID = 8
Cluster 1 Pattern[9][0 = 5, Member_ID = 9
Cluster 1 Pattern[9][1 = 0, Member_ID = 9
Pattern 10 assigned to cluster 1
Cluster 1 Pattern[8][0 = 4, Member_ID = 8
Cluster 1 Pattern[8][1 = 0, Member_ID = 8
Cluster 1 Pattern[9][0 = 5, Member_ID = 9
Cluster 1 Pattern[9][1 = 0, Member_ID = 9
Cluster 1 Pattern[10][0 = 4, Member_ID = 10
Cluster 1 Pattern[10][1 = 1, Member_ID = 10
Pattern 11 assigned to cluster 1
Cluster 1 Pattern[8][0 = 4, Member_ID = 8
Cluster 1 Pattern[8][1 = 0, Member_ID = 8
Cluster 1 Pattern[9][0 = 5, Member_ID = 9
Cluster 1 Pattern[9][1 = 0, Member_ID = 9
Cluster 1 Pattern[10][0 = 4, Member_ID = 10
Cluster 1 Pattern[10][1 = 1, Member_ID = 10
Cluster 1 Pattern[11][0 = 5, Member_ID = 11
Cluster 1 Pattern[11][1 = 1, Member_ID = 11

Cluster Centers:
	CLUSTER 0 ==>[0.5, 2]

	CLUSTER 1 ==>[4.5, 0.5]

 

The further the threshold value is from 1.0, the less strict it becomes in discriminating between patterns. Here, a smaller number of clusters are utilized.

 

Example Results 3

With a threshold value of 1.01, five clusters are created:

 

Pattern 0 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Pattern 1 assigned to cluster 0
Cluster 0 Pattern[0][0 = 0, Member_ID = 0
Cluster 0 Pattern[0][1 = 0, Member_ID = 0
Cluster 0 Pattern[1][0 = 1, Member_ID = 1
Cluster 0 Pattern[1][1 = 0, Member_ID = 1

Creating NEW cluster number: 1

Pattern 2 assigned to cluster 1
Cluster 1 Pattern[2][0 = 0, Member_ID = 2
Cluster 1 Pattern[2][1 = 1, Member_ID = 2
Pattern 3 assigned to cluster 1
Cluster 1 Pattern[2][0 = 0, Member_ID = 2
Cluster 1 Pattern[2][1 = 1, Member_ID = 2
Cluster 1 Pattern[3][0 = 1, Member_ID = 3
Cluster 1 Pattern[3][1 = 1, Member_ID = 3

Creating NEW cluster number: 2

Pattern 4 assigned to cluster 2
Cluster 2 Pattern[4][0 = 0, Member_ID = 4
Cluster 2 Pattern[4][1 = 3, Member_ID = 4
Pattern 5 assigned to cluster 2
Cluster 2 Pattern[4][0 = 0, Member_ID = 4
Cluster 2 Pattern[4][1 = 3, Member_ID = 4
Cluster 2 Pattern[5][0 = 1, Member_ID = 5
Cluster 2 Pattern[5][1 = 3, Member_ID = 5

Creating NEW cluster number: 3

Pattern 6 assigned to cluster 3
Cluster 3 Pattern[6][0 = 0, Member_ID = 6
Cluster 3 Pattern[6][1 = 4, Member_ID = 6
Pattern 7 assigned to cluster 3
Cluster 3 Pattern[6][0 = 0, Member_ID = 6
Cluster 3 Pattern[6][1 = 4, Member_ID = 6
Cluster 3 Pattern[7][0 = 1, Member_ID = 7
Cluster 3 Pattern[7][1 = 4, Member_ID = 7

Creating NEW cluster number: 4

Pattern 8 assigned to cluster 4
Cluster 4 Pattern[8][0 = 4, Member_ID = 8
Cluster 4 Pattern[8][1 = 0, Member_ID = 8
Pattern 9 assigned to cluster 4
Cluster 4 Pattern[8][0 = 4, Member_ID = 8
Cluster 4 Pattern[8][1 = 0, Member_ID = 8
Cluster 4 Pattern[9][0 = 5, Member_ID = 9
Cluster 4 Pattern[9][1 = 0, Member_ID = 9

Creating NEW cluster number: 5

Pattern 10 assigned to cluster 5
Cluster 5 Pattern[10][0 = 4, Member_ID = 10
Cluster 5 Pattern[10][1 = 1, Member_ID = 10
Pattern 11 assigned to cluster 5
Cluster 5 Pattern[10][0 = 4, Member_ID = 10
Cluster 5 Pattern[10][1 = 1, Member_ID = 10
Cluster 5 Pattern[11][0 = 5, Member_ID = 11
Cluster 5 Pattern[11][1 = 1, Member_ID = 11

Cluster Centers:
	CLUSTER 0 ==>[0.5, 0]

	CLUSTER 1 ==>[0.5, 1]

	CLUSTER 2 ==>[0.5, 3]

	CLUSTER 3 ==>[0.5, 4]

	CLUSTER 4 ==>[4.5, 0]

	CLUSTER 5 ==>[4.5, 1]

 

The closer the threshold value is to 1.0, the more strict it becomes in discriminating between patterns. Here, a greater number of clusters are utilized.

 

public void footer() {
About | Contact | Privacy Policy | Terms of Service | Site Map
Copyright© 2009-2012 John McCullock. All Rights Reserved.
}