public class Svdpp extends Object implements ComputeFunction<CfLongId,Svdpp.SvdppValue,Float,FloatMatrixMessage>
Modifier and Type | Class and Description |
---|---|
class |
Svdpp.InitItemsComputation |
class |
Svdpp.InitUsersComputation
This computation class is used to initialize the factors of the user nodes
in the very first superstep, and send the first updates to the item nodes.
|
class |
Svdpp.ItemComputation |
static class |
Svdpp.SvdppValue
A value in the Svdpp algorithm consists of (i) the baseline estimate, (ii)
the latent vector, and (iii) the weight vector.
|
class |
Svdpp.UserComputation |
ComputeFunction.Aggregators, ComputeFunction.Callback<K,VV,EV,Message>, ComputeFunction.InitCallback, ComputeFunction.MasterCallback, ComputeFunction.ReadAggregators, ComputeFunction.ReadWriteAggregators
Modifier and Type | Field and Description |
---|---|
static String |
BIAS_GAMMA
Bias learning rate parameter
|
static float |
BIAS_GAMMA_DEFAULT
Default value for bias learning rate
|
static String |
BIAS_LAMBDA
Bias regularization parameter.
|
static float |
BIAS_LAMBDA_DEFAULT
Default value for bias regularization parameter
|
static String |
FACTOR_GAMMA
Factor learning rate parameter
|
static float |
FACTOR_GAMMA_DEFAULT
Default value for factor learning rate
|
static String |
FACTOR_LAMBDA
Factor regularization parameter.
|
static float |
FACTOR_LAMBDA_DEFAULT
Default value for factor regularization parameter
|
static String |
ITERATIONS
Maximum number of iterations.
|
static int |
ITERATIONS_DEFAULT
Default value for ITERATIONS.
|
static String |
MAX_RATING
Max rating.
|
static float |
MAX_RATING_DEFAULT
Default maximum rating
|
static String |
MIN_RATING
Min rating.
|
static float |
MIN_RATING_DEFAULT
Default minimum rating
|
static String |
OVERALL_RATING_AGGREGATOR
Name of aggregator that aggregates all ratings.
|
static String |
RANDOM_SEED
Random seed.
|
static Long |
RANDOM_SEED_DEFAULT
Default random seed
|
static String |
RMSE_AGGREGATOR
Aggregator for the computation of RMSE
|
static String |
RMSE_TARGET
RMSE target
|
static float |
RMSE_TARGET_DEFAULT
Default value for parameter enabling the RMSE aggregator.
|
static String |
VECTOR_SIZE
Latent vector size.
|
static int |
VECTOR_SIZE_DEFAULT
Default latent vector size
|
Constructor and Description |
---|
Svdpp() |
Modifier and Type | Method and Description |
---|---|
void |
compute(int superstep,
VertexWithValue<CfLongId,Svdpp.SvdppValue> vertex,
Iterable<FloatMatrixMessage> messages,
Iterable<EdgeWithValue<CfLongId,Float>> edges,
ComputeFunction.Callback<CfLongId,Svdpp.SvdppValue,Float,FloatMatrixMessage> cb)
The function for computing a new vertex value or sending messages to the next superstep.
|
protected static float |
computePredictedRating(float meanRating,
float userBaseline,
float itemBaseline,
org.jblas.FloatMatrix user,
org.jblas.FloatMatrix item,
int numRatings,
org.jblas.FloatMatrix sumWeights,
float minRating,
float maxRating)
Computes the predicted rating r between a user and an item based on the
formula:
r = b + q^T * (p + (1/sqrt(N) * sum(y_i)))
|
protected static float |
computeUpdatedBaseLine(float baseline,
float predictedRating,
float observedRating,
float gamma,
float lambda)
Computes the updated baseline based on the formula:
|
protected long |
getTotalNumEdges(ComputeFunction.ReadAggregators aggregators) |
protected static float |
incrementValue(float baseline,
float step,
float gamma,
float lambda)
Increments a scalar value according to the formula:
|
protected static void |
incrementValue(org.jblas.FloatMatrix value,
org.jblas.FloatMatrix step,
float gamma,
float lambda)
Increments a vector according to the formula
|
void |
init(Map<String,?> configs,
ComputeFunction.InitCallback cb)
Initialize the ComputeFunction, this is the place to register aggregators.
|
void |
masterCompute(int superstep,
ComputeFunction.MasterCallback cb)
A function for performing sequential computations between supersteps.
|
void |
preSuperstep(int superstep,
ComputeFunction.Aggregators aggregators)
Prepare for computation.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
postSuperstep
public static final String OVERALL_RATING_AGGREGATOR
public static final String RMSE_TARGET
public static final float RMSE_TARGET_DEFAULT
public static final String ITERATIONS
public static final int ITERATIONS_DEFAULT
public static final String FACTOR_LAMBDA
public static final float FACTOR_LAMBDA_DEFAULT
public static final String FACTOR_GAMMA
public static final float FACTOR_GAMMA_DEFAULT
public static final String BIAS_LAMBDA
public static final float BIAS_LAMBDA_DEFAULT
public static final String BIAS_GAMMA
public static final float BIAS_GAMMA_DEFAULT
public static final String MAX_RATING
public static final float MAX_RATING_DEFAULT
public static final String MIN_RATING
public static final float MIN_RATING_DEFAULT
public static final String VECTOR_SIZE
public static final int VECTOR_SIZE_DEFAULT
public static final String RANDOM_SEED
public static final Long RANDOM_SEED_DEFAULT
public static final String RMSE_AGGREGATOR
protected static float computePredictedRating(float meanRating, float userBaseline, float itemBaseline, org.jblas.FloatMatrix user, org.jblas.FloatMatrix item, int numRatings, org.jblas.FloatMatrix sumWeights, float minRating, float maxRating)
where b: the baseline estimate of the user for the item q: the item vector p: the user vector N: number of ratings of the user y_i: the weight vector
meanRating
- the mean ratinguserBaseline
- the user baselineitemBaseline
- the item baselineuser
- the useritem
- the itemnumRatings
- the number of ratingssumWeights
- the sum of weightsmaxRating
- the max ratingminRating
- the min ratingprotected static float computeUpdatedBaseLine(float baseline, float predictedRating, float observedRating, float gamma, float lambda)
b := b + gamma * (error - lambda * b)
baseline
- the baselinepredictedRating
- the predicted ratingobservedRating
- the observed ratinggamma
- the gamma parameterlambda
- the lambda parameterprotected static float incrementValue(float baseline, float step, float gamma, float lambda)
v:= v + step - gamma*lambda*v;
baseline
- the baselinestep
- the step parametergamma
- the gamma parameterlambda
- the lambda parameterprotected static void incrementValue(org.jblas.FloatMatrix value, org.jblas.FloatMatrix step, float gamma, float lambda)
v:= v + step - gamma*lambda*v
value
- the valuestep
- the step parametergamma
- the gamma parameterlambda
- the lambda parameterpublic final void init(Map<String,?> configs, ComputeFunction.InitCallback cb)
ComputeFunction
init
in interface ComputeFunction<CfLongId,Svdpp.SvdppValue,Float,FloatMatrixMessage>
configs
- configuration parameterscb
- a callback for registering aggregatorspublic final void masterCompute(int superstep, ComputeFunction.MasterCallback cb)
ComputeFunction
masterCompute
in interface ComputeFunction<CfLongId,Svdpp.SvdppValue,Float,FloatMatrixMessage>
superstep
- the superstepcb
- a callback for writing to aggregators or halting the computationpublic void preSuperstep(int superstep, ComputeFunction.Aggregators aggregators)
ComputeFunction
preSuperstep
in interface ComputeFunction<CfLongId,Svdpp.SvdppValue,Float,FloatMatrixMessage>
superstep
- the superstepaggregators
- the aggregatorspublic void compute(int superstep, VertexWithValue<CfLongId,Svdpp.SvdppValue> vertex, Iterable<FloatMatrixMessage> messages, Iterable<EdgeWithValue<CfLongId,Float>> edges, ComputeFunction.Callback<CfLongId,Svdpp.SvdppValue,Float,FloatMatrixMessage> cb)
ComputeFunction
compute
in interface ComputeFunction<CfLongId,Svdpp.SvdppValue,Float,FloatMatrixMessage>
superstep
- the count of the current superstepvertex
- the current vertex with its valuemessages
- a Map of the source vertex and the message sent from the previous superstepedges
- the adjacent edges with their valuescb
- a callback for setting a new vertex value or sending messages to the next superstepprotected long getTotalNumEdges(ComputeFunction.ReadAggregators aggregators)
Copyright © 2020. All rights reserved.