|
Algorithm 1. K-means extraction of validation sets |
|
Input: All-training set data AT. Number of clustering centers k |
|
Output: Training set T. Verification set V. |
| 1: According to the two columns of data representing coordinates in All-Training sets AT, k cluster centers are randomly selected: . Define an empty list KC. |
| 2: Put the point into KC, where . |
| 3: for
to the last two columns of data in AT do |
| 4: for
to KC do
|
| 5: Repeat the process until the clustering center remains unchanged |
| 6: { |
| 7: //For each example, calculate the class it should belong to. |
| 8:
|
| 9: //For each class, recalculate its cluster center instead of the cluster center at the original location. |
| 10:
|
| 11: Put the point into KC. |
| 12: } |
| 13: end for
|
| 14: end for
|
| 15://The sample points closest to the cluster center are placed in the validation set V. |
| 16:
|
| 17: Put the data in row I of AT into V. |
| 18: Delete row I data from AT. |
| 19: T←AT |
| 20: return T, V |