Skip to content

MachineLeanring/MachineLearningKmeans

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MachineLearningKmeans

数据挖掘算法之 k-means(未完待续)


数据集

[(748, 2), (160, 453), (888, 395), (640, 583), (500, 812), (199, 359), (722, 998), (537, 877), (247, 927), (412, 869), (259, 101), (290, 403), (884, 419), (316, 581), (46, 799), (442, 891), (760, 451), (973, 556), (468, 445), (663, 97), (437, 255), (772, 738), (972, 910), (834, 797), (556, 730), (620, 224), (15, 143), (788, 636), (899, 807), (998, 319), (170, 747), (165, 298), (737, 922), (386, 221), (756, 872), (520, 459), (499, 18), (842, 302), (831, 202), (706, 292), (736, 707), (874, 446), (989, 134), (834, 511), (814, 144), (245, 936), (375, 65), (860, 270), (575, 641), (508, 408), (58, 832), (541, 362), (706, 574), (827, 988), (979, 402), (162, 148), (540, 784), (345, 97), (496, 715), (640, 658), (758, 47), (709, 508), (331, 683), (383, 810), (435, 735), (262, 926), (434, 278), (338, 102), (735, 263), (35, 686), (90, 884), (996, 267), (993, 752), (211, 819), (641, 237), (681, 606), (136, 402), (241, 350), (205, 97), (350, 40), (1, 85), (870, 25), (605, 770), (679, 0), (453, 236), (938, 551), (13, 24), (801, 803), (576, 861), (233, 179), (874, 279), (875, 965), (798, 849), (208, 117), (528, 580), (760, 189), (150, 23), (70, 453), (593, 948), (249, 591), (252, 53), (493, 916), (638, 247), (876, 754), (459, 733), (299, 68), (20, 336), (835, 589), (232, 556), (385, 940), (635, 949), (892, 645), (951, 18), (925, 867), (402, 601), (853, 827), (218, 721), (259, 203), (576, 483), (86, 942), (729, 397), (820, 577), (917, 592), (323, 747), (888, 830), (428, 105), (357, 566), (265, 982), (744, 237), (28, 585), (73, 592), (320, 12), (338, 567), (650, 610), (442, 684), (644, 477), (250, 973), (645, 947), (136, 329), (179, 579), (130, 153), (208, 518), (404, 897), (257, 699), (337, 570), (37, 21), (787, 511), (75, 323), (52, 512), (915, 312), (239, 188), (367, 173), (777, 480), (594, 296), (810, 30), (984, 982), (229, 891), (181, 405), (658, 331), (189, 296), (724, 552), (246, 475), (252, 756), (797, 266), (22, 360), (737, 993), (54, 926), (830, 180), (500, 462), (335, 400), (32, 138), (874, 17), (807, 270), (126, 631), (546, 177), (155, 477), (676, 37), (293, 931), (569, 447), (795, 538), (638, 900), (971, 268), (726, 315), (869, 501), (804, 366), (974, 759), (224, 269), (447, 659), (18, 111), (200, 754), (213, 918), (383, 947), (409, 366), (112, 907), (613, 381), (701, 341), (156, 841), (628, 196), (394, 446), (510, 75), (482, 754), (64, 1), (402, 11), (235, 701), (226, 513), (429, 632), (502, 46), (299, 859), (104, 871), (572, 597), (396, 456), (95, 910), (394, 200), (7, 475), (940, 795), (983, 74), (818, 53), (89, 804), (598, 410), (738, 162), (268, 185), (119, 835), (460, 271), (277, 143), (879, 387), (261, 598), (881, 169), (746, 675), (439, 396), (270, 927), (313, 496), (646, 96), (309, 683), (54, 729), (354, 512), (299, 333), (984, 528), (127, 634), (785, 182), (155, 937), (229, 387), (457, 238), (268, 342), (467, 647), (171, 986), (538, 993), (38, 164), (391, 770), (143, 665), (20, 786), (702, 674), (572, 242), (962, 568), (483, 583), (360, 952), (23, 192), (604, 635), (966, 613), (49, 107), (424, 69), (946, 450), (536, 122), (817, 443), (739, 183), (559, 376), (667, 277), (228, 455), (693, 220), (198, 864), (427, 521), (964, 823), (755, 316), (302, 968), (715, 162), (278, 918), (195, 961), (275, 41), (876, 873), (570, 212), (159, 5), (9, 285), (251, 131), (347, 920), (680, 380), (437, 435), (753, 174), (969, 436), (896, 789), (777, 132), (811, 343), (277, 729), (815, 824), (440, 321), (97, 125), (682, 5), (87, 683), (166, 368), (908, 402), (465, 211), (740, 37), (883, 702), (538, 840), (791, 552), (567, 830), (447, 611), (754, 945), (189, 622), (176, 372), (912, 791), (164, 697), (522, 485), (630, 31), (520, 590), (340, 89), (664, 827), (744, 131), (631, 771), (950, 954), (773, 750), (778, 263), (107, 899), (399, 55), (63, 477), (15, 764), (663, 101), (570, 389), (42, 775), (480, 956), (859, 482), (13, 799), (144, 119), (943, 967), (935, 342), (556, 893), (749, 584), (614, 794), (161, 264), (332, 235), (950, 681), (715, 667), (49, 376), (614, 195), (455, 31), (838, 737), (286, 709), (187, 6), (228, 949), (100, 992), (887, 863), (702, 899), (198, 238), (88, 81), (690, 700), (493, 265), (976, 928), (56, 835), (784, 621), (847, 396), (510, 567), (238, 849), (787, 823), (302, 78), (437, 882), (388, 821), (979, 856), (827, 398), (946, 4), (324, 691), (690, 736), (875, 290), (641, 542), (625, 294), (382, 267), (759, 440), (36, 945), (595, 697), (357, 23), (518, 938), (921, 145), (614, 275), (592, 315), (673, 711), (278, 711), (794, 674), (107, 404), (345, 869), (526, 193), (844, 937), (355, 223), (302, 939), (126, 346), (524, 827), (773, 433), (511, 150), (771, 910), (89, 630), (90, 588), (718, 596), (847, 962), (911, 846), (532, 647), (655, 166), (298, 229), (665, 255), (936, 782), (511, 978), (10, 67), (295, 304), (130, 682), (514, 507), (302, 269), (666, 184), (861, 321), (411, 517), (87, 373), (293, 256), (392, 413), (849, 741), (736, 527), (253, 600), (910, 460), (38, 704), (229, 932), (347, 148), (827, 22), (453, 70), (407, 436), (307, 667), (421, 648), (461, 777), (944, 842), (456, 375), (588, 623), (349, 154), (780, 620), (69, 148), (802, 882), (272, 66), (246, 19), (246, 574), (250, 949), (178, 307), (901, 990), (43, 42), (807, 827), (961, 501), (579, 267), (201, 951), (433, 315), (955, 25), (839, 698), (963, 454), (982, 449), (858, 65), (455, 870), (106, 764), (889, 327), (940, 748), (26, 780), (956, 313), (330, 801), (723, 298), (565, 673), (275, 589), (362, 913), (457, 735), (949, 686), (868, 605), (640, 428), (973, 85), (59, 245), (496, 575), (935, 127), (639, 553), (540, 38), (235, 977), (103, 973), (735, 396), (114, 820), (824, 870), (548, 63), (137, 632), (239, 936), (583, 780), (367, 843), (711, 713), (800, 90), (3, 253), (332, 853), (263, 676), (791, 323), (632, 849), (803, 507), (403, 54), (964, 452), (884, 674), (120, 510), (631, 470), (402, 582), (289, 127)]

说明

本程序中的数据为随机生成,如果你需要,也可以使用文件输入。只需要修改如下位置的代码即可:

public class KmeansClient {
    
    public static void main(String[] args) {
        new KmeansClient().execute(10, 100);
    }
    
    private void execute(int k, int threshold) {
        ( ... 此处省略 N  ... )
        
        List<Point2D> point2ds = KmeansUtils.randomPoint2DSet(1000, 1000, 500);
        List<Centroid> centroids = KmeansUtils.randomSelectCentroidSet(point2ds, k);
        
        ( ... 此处省略 N  ... )
    }
}

可视化

将上面的数据代入程序,可以获取如下可视化结果。只是这个结果并不是一个确定的结果,会因结束条件、始初质心的选取不同而异(本程序的初始质心选取为随机选取)。 此处使用的是 Gnuplot 可视化工具。执行可视化代码如下:

plot "F:/Temp/kmeans/points_0" with linespoints pointtype 1 pointsize 1,\
"F:/Temp/kmeans/points_1" with linespoints pointtype 2 pointsize 1,\
"F:/Temp/kmeans/points_2" with linespoints pointtype 3 pointsize 1,\
"F:/Temp/kmeans/points_3" with linespoints pointtype 4 pointsize 1,\
"F:/Temp/kmeans/points_4" with linespoints pointtype 5 pointsize 1,\
"F:/Temp/kmeans/points_5" with linespoints pointtype 6 pointsize 1,\
"F:/Temp/kmeans/points_6" with linespoints pointtype 7 pointsize 1,\
"F:/Temp/kmeans/points_7" with linespoints pointtype 8 pointsize 1,\
"F:/Temp/kmeans/points_8" with linespoints pointtype 9 pointsize 1,\
"F:/Temp/kmeans/points_9" with linespoints pointtype 10 pointsize 1

gnuplot


                                  本人CSDN博客 点击链接

About

数据挖掘算法之 k-means

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages