我需要在java中使用k-means算法执行文档聚类的步骤.对我来说,轻松提供这些步骤非常有用.提前致谢.
我有文本文件
0B85 61
0B86 6161
0B86 41
0B87 69
0B88 6969
0B88 49
0B89 75
0B8A 7575
0B8F 6565
Run Code Online (Sandbox Code Playgroud)
我想把这个字符串写成二维数组.(即)String read[0][0]=0B85和String read[0][1]=61.请使用java建议任何想法.提前致谢.
我的输入文件将如下所示
?????? 1 ?????? 2 ?????? 3 ?????? 4 ?????? 5 ?????? 6 ?????? 7 ?????? 8 ?????? 9 ?????? 10 ?????? 11 ???????? 1 ???????? 2 ???? 1 ???? 2 ???? 3 ???? 4 ???? 5
我的输出想成为
?????? 11 ???????? 2 ???? 5
如何使用java程序选择具有最大值的每个单词.请给我任何想法.提前致谢.
如何从Arraylist带有索引位置的 a 中找到最大值?
ArrayList ar = new ArrayList();
ar.add(2); // position 0
ar.add(4); // position 1
ar.add(12); // position 2
ar.add(10); // position 3
ar.add(12); // position 4
String obj = Collections.max(ar);
int index = ar.indexOf(obj);
System.out.println("obj max value is " + obj + " and index position is " + index);
Run Code Online (Sandbox Code Playgroud)
上面的程序只是将输出作为第一个具有 value12和 index position 的max 对象返回2。
但我的实际输出应该是索引位置2和4(因为最大值12出现在两个索引位置)。