@Override protected void setup(Context ctx) throws IOException, InterruptedException { Configuration conf = ctx.getConfiguration(); Path pathToU = new Path(conf.get(USER_FEATURES_PATH)); Path pathToM = new Path(conf.get(ITEM_FEATURES_PATH)); U = ALS.readMatrixByRows(pathToU, conf); M = ALS.readMatrixByRows(pathToM, conf); usesLongIDs = conf.getBoolean(ParallelALSFactorizationJob.USES_LONG_IDS, false); }
@Override OpenIntObjectHashMap<Vector> createSharedInstance(Context ctx) throws IOException { Configuration conf = ctx.getConfiguration(); int numEntities = Integer.parseInt(conf.get(ParallelALSFactorizationJob.NUM_ENTITIES)); return ALS.readMatrixByRowsFromDistributedCache(numEntities, conf); }
@Override protected void map(IntWritable userOrItemID, VectorWritable ratingsWritable, Context ctx) throws IOException, InterruptedException { OpenIntObjectHashMap<Vector> uOrM = getSharedInstance(); uiOrmj.set(ALS.solveExplicit(ratingsWritable, uOrM, lambda, numFeatures)); ctx.write(userOrItemID, uiOrmj); }
Vector averageRatings = ALS.readFirstRow(getTempPath("averageRatings"), getConf());
@Override protected void map(IntWritable userOrItemID, VectorWritable ratingsWritable, Context ctx) throws IOException, InterruptedException { OpenIntObjectHashMap<Vector> uOrM = getSharedInstance(); uiOrmj.set(ALS.solveExplicit(ratingsWritable, uOrM, lambda, numFeatures)); ctx.write(userOrItemID, uiOrmj); }
Vector averageRatings = ALS.readFirstRow(getTempPath("averageRatings"), getConf());
@Override OpenIntObjectHashMap<Vector> createSharedInstance(Context ctx) throws IOException { Configuration conf = ctx.getConfiguration(); int numEntities = Integer.parseInt(conf.get(ParallelALSFactorizationJob.NUM_ENTITIES)); return ALS.readMatrixByRowsFromDistributedCache(numEntities, conf); }
@Override protected void setup(Context ctx) throws IOException, InterruptedException { Configuration conf = ctx.getConfiguration(); Path pathToU = new Path(conf.get(USER_FEATURES_PATH)); Path pathToM = new Path(conf.get(ITEM_FEATURES_PATH)); U = ALS.readMatrixByRows(pathToU, conf); M = ALS.readMatrixByRows(pathToM, conf); usesLongIDs = conf.getBoolean(ParallelALSFactorizationJob.USES_LONG_IDS, false); }
@Override protected void map(IntWritable userOrItemID, VectorWritable ratingsWritable, Context ctx) throws IOException, InterruptedException { OpenIntObjectHashMap<Vector> uOrM = getSharedInstance(); uiOrmj.set(ALS.solveExplicit(ratingsWritable, uOrM, lambda, numFeatures)); ctx.write(userOrItemID, uiOrmj); }
Vector averageRatings = ALS.readFirstRow(getTempPath("averageRatings"), getConf());
@Override OpenIntObjectHashMap<Vector> createSharedInstance(Context ctx) throws IOException { Configuration conf = ctx.getConfiguration(); int numEntities = Integer.parseInt(conf.get(ParallelALSFactorizationJob.NUM_ENTITIES)); return ALS.readMatrixByRowsFromDistributedCache(numEntities, conf); }
@Override protected void setup(Context ctx) throws IOException, InterruptedException { Configuration conf = ctx.getConfiguration(); Path pathToU = new Path(conf.get(USER_FEATURES_PATH)); Path pathToM = new Path(conf.get(ITEM_FEATURES_PATH)); U = ALS.readMatrixByRows(pathToU, conf); M = ALS.readMatrixByRows(pathToM, conf); usesLongIDs = conf.getBoolean(ParallelALSFactorizationJob.USES_LONG_IDS, false); }
@Override ImplicitFeedbackAlternatingLeastSquaresSolver createSharedInstance(Context ctx) throws IOException { Configuration conf = ctx.getConfiguration(); double lambda = Double.parseDouble(conf.get(ParallelALSFactorizationJob.LAMBDA)); double alpha = Double.parseDouble(conf.get(ParallelALSFactorizationJob.ALPHA)); int numFeatures = conf.getInt(ParallelALSFactorizationJob.NUM_FEATURES, -1); int numEntities = Integer.parseInt(conf.get(ParallelALSFactorizationJob.NUM_ENTITIES)); Preconditions.checkArgument(numFeatures > 0, "numFeatures must be greater then 0!"); return new ImplicitFeedbackAlternatingLeastSquaresSolver(numFeatures, lambda, alpha, ALS.readMatrixByRowsFromDistributedCache(numEntities, conf)); }
@Override Pair<OpenIntObjectHashMap<Vector>, OpenIntObjectHashMap<Vector>> createSharedInstance(Context ctx) { Configuration conf = ctx.getConfiguration(); Path pathToU = new Path(conf.get(RecommenderJob.USER_FEATURES_PATH)); Path pathToM = new Path(conf.get(RecommenderJob.ITEM_FEATURES_PATH)); OpenIntObjectHashMap<Vector> U = ALS.readMatrixByRows(pathToU, conf); OpenIntObjectHashMap<Vector> M = ALS.readMatrixByRows(pathToM, conf); return new Pair<>(U, M); }
@Override ImplicitFeedbackAlternatingLeastSquaresSolver createSharedInstance(Context ctx) throws IOException { Configuration conf = ctx.getConfiguration(); double lambda = Double.parseDouble(conf.get(ParallelALSFactorizationJob.LAMBDA)); double alpha = Double.parseDouble(conf.get(ParallelALSFactorizationJob.ALPHA)); int numFeatures = conf.getInt(ParallelALSFactorizationJob.NUM_FEATURES, -1); int numEntities = Integer.parseInt(conf.get(ParallelALSFactorizationJob.NUM_ENTITIES)); Preconditions.checkArgument(numFeatures > 0, "numFeatures must be greater then 0!"); return new ImplicitFeedbackAlternatingLeastSquaresSolver(numFeatures, lambda, alpha, ALS.readMatrixByRowsFromDistributedCache(numEntities, conf), 1); }
@Override Pair<OpenIntObjectHashMap<Vector>, OpenIntObjectHashMap<Vector>> createSharedInstance(Context ctx) { Configuration conf = ctx.getConfiguration(); Path pathToU = new Path(conf.get(RecommenderJob.USER_FEATURES_PATH)); Path pathToM = new Path(conf.get(RecommenderJob.ITEM_FEATURES_PATH)); OpenIntObjectHashMap<Vector> U = ALS.readMatrixByRows(pathToU, conf); OpenIntObjectHashMap<Vector> M = ALS.readMatrixByRows(pathToM, conf); return new Pair<OpenIntObjectHashMap<Vector>, OpenIntObjectHashMap<Vector>>(U, M); }
@Override ImplicitFeedbackAlternatingLeastSquaresSolver createSharedInstance(Context ctx) throws IOException { Configuration conf = ctx.getConfiguration(); double lambda = Double.parseDouble(conf.get(ParallelALSFactorizationJob.LAMBDA)); double alpha = Double.parseDouble(conf.get(ParallelALSFactorizationJob.ALPHA)); int numFeatures = conf.getInt(ParallelALSFactorizationJob.NUM_FEATURES, -1); int numEntities = Integer.parseInt(conf.get(ParallelALSFactorizationJob.NUM_ENTITIES)); Preconditions.checkArgument(numFeatures > 0, "numFeatures must be greater then 0!"); return new ImplicitFeedbackAlternatingLeastSquaresSolver(numFeatures, lambda, alpha, ALS.readMatrixByRowsFromDistributedCache(numEntities, conf), 1); }
@Override Pair<OpenIntObjectHashMap<Vector>, OpenIntObjectHashMap<Vector>> createSharedInstance(Context ctx) { Configuration conf = ctx.getConfiguration(); Path pathToU = new Path(conf.get(RecommenderJob.USER_FEATURES_PATH)); Path pathToM = new Path(conf.get(RecommenderJob.ITEM_FEATURES_PATH)); OpenIntObjectHashMap<Vector> U = ALS.readMatrixByRows(pathToU, conf); OpenIntObjectHashMap<Vector> M = ALS.readMatrixByRows(pathToM, conf); return new Pair<OpenIntObjectHashMap<Vector>, OpenIntObjectHashMap<Vector>>(U, M); }