Dear Wiki user, You have subscribed to a wiki page or wiki category on "Hama Wiki" for change notification.
The following page has been changed by udanax: http://wiki.apache.org/hama/TraditionalCollaborativeFiltering ------------------------------------------------------------------------------ public static void main(String[] args) { HamaConfiguration conf = new HamaConfiguration(); - - Matrix userByItem = new Matrix(conf, "userByItem"); + Matrix userByItem = new Matrix(conf, "userByItem"); - + - // Build an user by item matrix + // 1. Build an user by item matrix for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { userByItem.set(i, j, data[i][j]); } } - // Get the pair set of all row key combinations + // 2. Get the pair set of all row key combinations Combination x = new Combination(data.length, 2); - // |a|·|b|cos(q) calculation + // 3. |a|·|b|cos(q) calculation while (x.hasMore()) { int[] pair = x.getNext(); System.out.print("Similarity: (" + pair[0] + ", " + pair[1] + ") = "); @@ -38, +37 @@ Vector v2 = userByItem.getRow(pair[1]); double similarity = v1.dot(v2); - // Collect the similarity result of the two users + // 4. Collect the similarity result of the two users System.out.println(similarity); } + // Each part can be applied to large-scale job scheduling using Map/Reduce. } static class Combination {
