List of usage examples for org.apache.mahout.math DenseVector DenseVector
public DenseVector(DenseVector values, boolean shallowCopy)
From source file:com.innometrics.integration.app.recommender.ml.als.ALSWRFactorizer.java
License:Apache License
protected static Vector ratingVector(PreferenceArray prefs) { double[] ratings = new double[prefs.length()]; for (int n = 0; n < prefs.length(); n++) { ratings[n] = prefs.get(n).getValue(); }/*from w w w.j a va 2 s . c o m*/ return new DenseVector(ratings, true); }
From source file:com.innometrics.integration.app.recommender.ml.als.ALSWRFactorizer.java
License:Apache License
protected OpenIntObjectHashMap<Vector> itemFeaturesMapping(LongPrimitiveIterator itemIDs, int numItems, double[][] featureMatrix) { OpenIntObjectHashMap<Vector> mapping = new OpenIntObjectHashMap<Vector>(numItems); while (itemIDs.hasNext()) { long itemID = itemIDs.next(); int itemIndex = itemIndex(itemID); mapping.put(itemIndex, new DenseVector(featureMatrix[itemIndex(itemID)], true)); }/*from w ww. j av a2s . co m*/ return mapping; }
From source file:com.innometrics.integration.app.recommender.ml.als.ALSWRFactorizer.java
License:Apache License
protected OpenIntObjectHashMap<Vector> userFeaturesMapping(LongPrimitiveIterator userIDs, int numUsers, double[][] featureMatrix) { OpenIntObjectHashMap<Vector> mapping = new OpenIntObjectHashMap<Vector>(numUsers); while (userIDs.hasNext()) { long userID = userIDs.next(); int userIndex = userIndex(userID); mapping.put(userIndex, new DenseVector(featureMatrix[userIndex(userID)], true)); }// w w w . j a v a 2 s. c om return mapping; }
From source file:org.codelibs.elasticsearch.taste.recommender.svd.ALSWRFactorizer.java
License:Apache License
protected static Vector ratingVector(final PreferenceArray prefs) { final double[] ratings = new double[prefs.length()]; for (int n = 0; n < prefs.length(); n++) { ratings[n] = prefs.get(n).getValue(); }/* w w w .ja v a2s . c om*/ return new DenseVector(ratings, true); }
From source file:org.codelibs.elasticsearch.taste.recommender.svd.ALSWRFactorizer.java
License:Apache License
protected OpenIntObjectHashMap<Vector> itemFeaturesMapping(final LongPrimitiveIterator itemIDs, final int numItems, final double[][] featureMatrix) { final OpenIntObjectHashMap<Vector> mapping = new OpenIntObjectHashMap<Vector>(numItems); while (itemIDs.hasNext()) { final long itemID = itemIDs.next(); mapping.put((int) itemID, new DenseVector(featureMatrix[itemIndex(itemID)], true)); }/*from w w w . j av a 2s .c o m*/ return mapping; }
From source file:org.codelibs.elasticsearch.taste.recommender.svd.ALSWRFactorizer.java
License:Apache License
protected OpenIntObjectHashMap<Vector> userFeaturesMapping(final LongPrimitiveIterator userIDs, final int numUsers, final double[][] featureMatrix) { final OpenIntObjectHashMap<Vector> mapping = new OpenIntObjectHashMap<Vector>(numUsers); while (userIDs.hasNext()) { final long userID = userIDs.next(); mapping.put((int) userID, new DenseVector(featureMatrix[userIndex(userID)], true)); }/*from ww w . j a va 2 s .c om*/ return mapping; }
From source file:org.gpfvic.mahout.cf.taste.impl.recommender.svd.ALSWRFactorizer.java
License:Apache License
protected OpenIntObjectHashMap<Vector> itemFeaturesMapping(LongPrimitiveIterator itemIDs, int numItems, double[][] featureMatrix) { OpenIntObjectHashMap<Vector> mapping = new OpenIntObjectHashMap<>(numItems); while (itemIDs.hasNext()) { long itemID = itemIDs.next(); int itemIndex = itemIndex(itemID); mapping.put(itemIndex, new DenseVector(featureMatrix[itemIndex(itemID)], true)); }/* w w w. j av a 2 s . c om*/ return mapping; }
From source file:org.gpfvic.mahout.cf.taste.impl.recommender.svd.ALSWRFactorizer.java
License:Apache License
protected OpenIntObjectHashMap<Vector> userFeaturesMapping(LongPrimitiveIterator userIDs, int numUsers, double[][] featureMatrix) { OpenIntObjectHashMap<Vector> mapping = new OpenIntObjectHashMap<>(numUsers); while (userIDs.hasNext()) { long userID = userIDs.next(); int userIndex = userIndex(userID); mapping.put(userIndex, new DenseVector(featureMatrix[userIndex(userID)], true)); }// w ww .ja v a2 s .c om return mapping; }
From source file:org.plista.kornakapi.core.optimizer.ErrorALSWRFactorizer.java
License:Apache License
protected OpenIntObjectHashMap<Vector> itemFeaturesMapping(LongPrimitiveIterator itemIDs, int numItems, double[][] featureMatrix) { OpenIntObjectHashMap<Vector> mapping = new OpenIntObjectHashMap<Vector>(numItems); while (itemIDs.hasNext()) { long itemID = itemIDs.next(); mapping.put((int) itemID, new DenseVector(featureMatrix[itemIndex(itemID)], true)); }//from w w w .ja va 2 s .co m return mapping; }
From source file:org.plista.kornakapi.core.optimizer.ErrorALSWRFactorizer.java
License:Apache License
protected OpenIntObjectHashMap<Vector> userFeaturesMapping(LongPrimitiveIterator userIDs, int numUsers, double[][] featureMatrix) { OpenIntObjectHashMap<Vector> mapping = new OpenIntObjectHashMap<Vector>(numUsers); while (userIDs.hasNext()) { long userID = userIDs.next(); mapping.put((int) userID, new DenseVector(featureMatrix[userIndex(userID)], true)); }/* w w w . j a v a 2s . co m*/ return mapping; }