协同过滤算法,java实现

协同过滤算法

https://blog.csdn.net/yimingsilence/article/details/54934302

欧几里德距离评价算法(集体智慧编程)

http://lobert.iteye.com/blog/2024908


自己的实现


public static BigInteger Math(int i, int j) {
    int temp = i - j;
    String info = String.valueOf((int) Math.pow(temp, 2));
    return new BigInteger(info);
}

public static String Euclidean_Distance(List<Integer> one, List<Integer> two) {
    Iterator o = one.iterator();
    Iterator t = two.iterator();

    BigInteger sum = new BigInteger(String.valueOf(0));
    for (int i = 0; i < one.size(); i++) {
        BigInteger bigInteger = Math((int) o.next(), (int) t.next());
        sum = sum.add(bigInteger);
    }
    return String.valueOf(Math.sqrt(sum.intValue()));
}

public static void main(String[] args) {
    List<Integer> list_one = new ArrayList<>();
    List<Integer> list_two = new ArrayList<>();
    Random random = new Random();
    for (int i = 0; i < 100; i++) {
        list_one.add(random.nextInt(100));
        list_two.add(random.nextInt(100));
    }

    String info = Euclidean_Distance(list_one, list_two);
    System.out.println(info);



}
总结:最简单的就是简单的像勾股定理,k临近算法也是一样把
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页