Examples of TrainingLoopController


Examples of org.grouplens.lenskit.iterative.TrainingLoopController

            // TODO Use vectorz vectors instead of raw arrays
            double uoff[] = new double[snapshot.getUserIds().size()];
            double ioff[] = new double[snapshot.getItemIds().size()];

            final TrainingLoopController trainingController = stoppingCondition.newLoop();
            double rmse = 0.0;
            while (trainingController.keepTraining(rmse)) {
                double sse = 0;
                for (IndexedPreference r : ratings) {
                    final int uidx = r.getUserIndex();
                    final int iidx = r.getItemIndex();
                    final double p = mean + uoff[uidx] + ioff[iidx];
                    final double err = r.getValue() - p;
                    uoff[uidx] += learningRate * (err - regularizationFactor * Math.abs(uoff[uidx]));
                    ioff[iidx] += learningRate * (err - regularizationFactor * Math.abs(ioff[iidx]));
                    sse += err * err;
                }
                rmse = Math.sqrt(sse / ratings.size());

                logger.debug("finished iteration {} (RMSE={})", trainingController.getIterationCount(), rmse);
            }

            logger.info("trained baseline on {} ratings in {} iterations (final rmse={})", ratings.size(), trainingController.getIterationCount(), rmse);

            // Convert the uoff array to a SparseVector
            MutableSparseVector svuoff = Vectors.fromArray(snapshot.userIndex(), uoff);
            // Convert the ioff array to a SparseVector
            MutableSparseVector svioff = Vectors.fromArray(snapshot.itemIndex(), ioff);
View Full Code Here

Examples of org.grouplens.lenskit.iterative.TrainingLoopController

    protected void trainFeature(int feature, TrainingEstimator estimates,
                                Vector userFeatureVector, Vector itemFeatureVector,
                                FeatureInfo.Builder fib) {
        double rmse = Double.MAX_VALUE;
        double trail = initialValue * initialValue * (featureCount - feature - 1);
        TrainingLoopController controller = rule.getTrainingLoopController();
        Collection<IndexedPreference> ratings = snapshot.getRatings();
        while (controller.keepTraining(rmse)) {
            rmse = doFeatureIteration(estimates, ratings, userFeatureVector, itemFeatureVector, trail);
            fib.addTrainingRound(rmse);
            logger.trace("iteration {} finished with RMSE {}", controller.getIterationCount(), rmse);
        }
    }
View Full Code Here

Examples of org.grouplens.lenskit.iterative.TrainingLoopController

                tails.set(e, utail.dotProduct(ivec));
            }
        }

        double rmse = Double.MAX_VALUE;
        TrainingLoopController controller = rule.getTrainingLoopController();
        while (controller.keepTraining(rmse)) {
            rmse = doFeatureIteration(user, uprefs, ratings, estimates, feature, tails);
        }
    }
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.