public class FunkSVDModelBuilder extends Object implements javax.inject.Provider<FunkSVDModel>
This recommender builder constructs an SVD-based recommender using gradient descent, as pioneered by Simon Funk. It also incorporates the regularizations Funk did. These are documented in Netflix Update: Try This at Home. This implementation is based in part on Timely Development's sample code.
Modifier and Type | Field and Description |
---|---|
protected int |
featureCount |
protected double |
initialValue |
protected FunkSVDUpdateRule |
rule |
protected PreferenceSnapshot |
snapshot |
Constructor and Description |
---|
FunkSVDModelBuilder(PreferenceSnapshot snapshot,
FunkSVDUpdateRule rule,
int featureCount,
double initVal) |
Modifier and Type | Method and Description |
---|---|
protected double |
doFeatureIteration(TrainingEstimator estimates,
Collection<IndexedPreference> ratings,
mikera.vectorz.Vector userFeatureVector,
mikera.vectorz.Vector itemFeatureVector,
double trail)
Do a single feature iteration.
|
FunkSVDModel |
get() |
protected void |
summarizeFeature(mikera.vectorz.AVector ufv,
mikera.vectorz.AVector ifv,
FeatureInfo.Builder fib)
Add a feature's summary to the feature info builder.
|
protected void |
trainFeature(int feature,
TrainingEstimator estimates,
mikera.vectorz.Vector userFeatureVector,
mikera.vectorz.Vector itemFeatureVector,
FeatureInfo.Builder fib)
Train a feature using a collection of ratings.
|
protected final int featureCount
protected final PreferenceSnapshot snapshot
protected final double initialValue
protected final FunkSVDUpdateRule rule
@Inject public FunkSVDModelBuilder(@Nonnull PreferenceSnapshot snapshot, @Nonnull FunkSVDUpdateRule rule, @FeatureCount int featureCount, @InitialFeatureValue double initVal)
public FunkSVDModel get()
get
in interface javax.inject.Provider<FunkSVDModel>
protected void trainFeature(int feature, TrainingEstimator estimates, mikera.vectorz.Vector userFeatureVector, mikera.vectorz.Vector itemFeatureVector, FeatureInfo.Builder fib)
doFeatureIteration(TrainingEstimator, Collection, Vector, Vector, double)
to train
the feature. It can be overridden to customize the feature training strategy.
We use the estimator to maintain the estimate up through a particular feature value, rather than recomputing the entire kernel value every time. This hopefully speeds up training. It means that we always tell the updater we are training feature 0, but use a subvector that starts with the current feature.
feature
- The number of the current feature.estimates
- The current estimator. This method is not expected to update the
estimator.userFeatureVector
- The user feature values. This has been initialized to the initial value,
and may be reused between features.itemFeatureVector
- The item feature values. This has been initialized to the initial value,
and may be reused between features.fib
- The feature info builder. This method is only expected to add information
about its training rounds to the builder; the caller takes care of feature
number and summary data.doFeatureIteration(TrainingEstimator, Collection, Vector, Vector, double)
,
summarizeFeature(AVector, AVector, FeatureInfo.Builder)
protected double doFeatureIteration(TrainingEstimator estimates, Collection<IndexedPreference> ratings, mikera.vectorz.Vector userFeatureVector, mikera.vectorz.Vector itemFeatureVector, double trail)
estimates
- The estimates.ratings
- The ratings to train on.userFeatureVector
- The user column vector for the current feature.itemFeatureVector
- The item column vector for the current feature.trail
- The sum of the remaining user-item-feature values.protected void summarizeFeature(mikera.vectorz.AVector ufv, mikera.vectorz.AVector ifv, FeatureInfo.Builder fib)
ufv
- The user values.ifv
- The item values.fib
- The feature info builder.