public class UserKNN extends Recommender
Modifier and Type | Class and Description |
---|---|
static class |
UserKNN.AggregationApproach
Available aggregation approaches to merge k-nearest neighbors ratings
|
Modifier and Type | Field and Description |
---|---|
protected UserKNN.AggregationApproach |
aggregationApproach
Aggregation approach used to aggregate k-nearest neighbors ratings
|
protected UserSimilarityMetric |
metric
Similarity metric to compute the similarity between two users
|
protected int[][] |
neighbors
Contains the neighbors indexes of each user
|
protected int |
numberOfNeighbors
Number of neighbors (k)
|
datamodel
Constructor and Description |
---|
UserKNN(DataModel datamodel,
int numberOfNeighbors,
UserSimilarityMetric metric,
UserKNN.AggregationApproach aggregationApproach)
Recommender constructor
|
UserKNN(DataModel datamodel,
Map<String,Object> params)
Recommender constructor from a Map containing the recommender's hyper-parameters values.
|
Modifier and Type | Method and Description |
---|---|
void |
fit()
Estimates model parameters given the hyper-parameters
|
double |
predict(int userIndex,
int itemIndex)
Computes a rating prediction
|
String |
toString() |
getDataModel, predict
protected int numberOfNeighbors
protected UserSimilarityMetric metric
protected UserKNN.AggregationApproach aggregationApproach
protected int[][] neighbors
public UserKNN(DataModel datamodel, Map<String,Object> params)
datamodel
- DataModel instanceparams
- Recommender's hyper-parameters valuespublic UserKNN(DataModel datamodel, int numberOfNeighbors, UserSimilarityMetric metric, UserKNN.AggregationApproach aggregationApproach)
datamodel
- DataModel instancenumberOfNeighbors
- Number of neighbors (k)metric
- Similarity metric to compute the similarity between two usersaggregationApproach
- Aggregation approach used to aggregate k-nearest neighbors ratingspublic void fit()
Recommender
fit
in class Recommender
public double predict(int userIndex, int itemIndex)
Recommender
predict
in class Recommender
userIndex
- Index of the user in the array of Users of the DataModel instanceitemIndex
- Index of the item in the array of Items of the DataModel instanceCopyright © 2020. All rights reserved.