public final class LiveUserItemBiasModel extends java.lang.Object implements BiasModel
Bias model that provides global, user, and item biases. The global and item biases are precomputed and are not refreshed based on user data added since the model build, but the user bias (mean rating from the rating DAO) is recomputed live based on a RatingVectorPDAO
.
Note: The getUserBiases()
method will always return an empty map.
Constructor and Description |
---|
LiveUserItemBiasModel(ItemBiasModel base,
RatingVectorPDAO dao)
Construct a new bias model.
|
Modifier and Type | Method and Description |
---|---|
double |
getIntercept()
Get the global bias (intercept).
|
double |
getItemBias(long item)
Get the item bias.
|
Long2DoubleMap |
getItemBiases()
Get the map of all known item biases.
|
Long2DoubleMap |
getItemBiases(LongSet items)
Get a set of item biases.
|
double |
getUserBias(long user)
Get the user bias.
|
Long2DoubleMap |
getUserBiases()
Return an empty map.
|
Long2DoubleMap |
getUserBiases(LongSet users)
Get a set of user biases.
|
@Inject public LiveUserItemBiasModel(ItemBiasModel base, RatingVectorPDAO dao)
Construct a new bias model.
base
- An item bias model to use as the base model.dao
- The rating vector DAO to fetch user data.public double getIntercept()
BiasModel
Get the global bias (intercept).
getIntercept
in interface BiasModel
public double getUserBias(long user)
BiasModel
Get the user bias.
getUserBias
in interface BiasModel
user
- The user ID.public double getItemBias(long item)
BiasModel
Get the item bias.
getItemBias
in interface BiasModel
item
- The item ID.public Long2DoubleMap getUserBiases(LongSet users)
BiasModel
Get a set of user biases.
getUserBiases
in interface BiasModel
users
- The users whose biases are to be returned.Long2DoubleMap.defaultReturnValue()
will be 0.public Long2DoubleMap getItemBiases(LongSet items)
BiasModel
Get a set of item biases.
getItemBiases
in interface BiasModel
items
- The items whose biases are to be returned.Long2DoubleMap.defaultReturnValue()
will be 0.public Long2DoubleMap getUserBiases()
Return an empty map. This may make this bias model unsuitable in some applications.
getUserBiases
in interface BiasModel
public Long2DoubleMap getItemBiases()
BiasModel
Get the map of all known item biases.
getItemBiases
in interface BiasModel