Package org.apache.mahout.math.als

Examples of org.apache.mahout.math.als.AlternateLeastSquaresSolver.solve()


              List<Vector> featureVectors = new ArrayList<Vector>();
              while (itemIDsFromUser.hasNext()) {
                long itemID = itemIDsFromUser.nextLong();
                featureVectors.add(features.getItemFeatureColumn(itemIndex(itemID)));
              }
              Vector userFeatures = solver.solve(featureVectors, ratingVector(userPrefs), lambda, numFeatures);
              features.setFeatureColumnInU(userIndex(userID), userFeatures);
            }
          });
        }
      } finally {
View Full Code Here


              List<Vector> featureVectors = new ArrayList<Vector>();
              for (Preference pref : itemPrefs) {
                long userID = pref.getUserID();
                featureVectors.add(features.getUserFeatureColumn(userIndex(userID)));
              }
              Vector itemFeatures = solver.solve(featureVectors, ratingVector(itemPrefs), lambda, numFeatures);
              features.setFeatureColumnInM(itemIndex(itemID), itemFeatures);
            }
          });
        }
      } finally {
View Full Code Here

    double lambda = 0.01;
    Vector ratings = new DenseVector(new double[] { 2, 1 });
    Vector col1 = new DenseVector(new double[] { 1, 2 });
    Vector col2 = new DenseVector(new double[] { 3, 4 });

    Vector result = solver.solve(Arrays.asList(col1, col2), ratings, lambda, numFeatures);
    Vector.Element[] elems = new Vector.Element[result.size()];
    for (int n = 0; n < result.size(); n++) {
      elems[n] = result.getElement(n);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.