public class ItemKNN extends Recommender
Modifier and Type | Class and Description |
---|---|
static class |
ItemKNN.AggregationApproach
Available aggregation approaches to merge k-nearest neighbors ratings
|
Modifier and Type | Field and Description |
---|---|
protected ItemKNN.AggregationApproach |
aggregationApproach
Aggregation approach used to aggregate k-nearest neighbors ratings
|
protected ItemSimilarityMetric |
metric
Similarity metric to compute the similarity between two items
|
protected int[][] |
neighbors
Contains the neighbors indexes of each item
|
protected int |
numberOfNeighbors
Number of neighbors (k)
|
datamodel
Constructor and Description |
---|
ItemKNN(DataModel datamodel,
int numberOfNeighbors,
ItemSimilarityMetric metric,
ItemKNN.AggregationApproach aggregationApproach)
Recommender constructor
|
ItemKNN(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 ItemSimilarityMetric metric
protected ItemKNN.AggregationApproach aggregationApproach
protected int[][] neighbors
public ItemKNN(DataModel datamodel, Map<String,Object> params)
datamodel
- DataModel instanceparams
- Recommender's hyper-parameters valuespublic ItemKNN(DataModel datamodel, int numberOfNeighbors, ItemSimilarityMetric metric, ItemKNN.AggregationApproach aggregationApproach)
datamodel
- DataModel instancenumberOfNeighbors
- Number of neighbors (k)metric
- Similarity metric to compute the similarity between two itemsaggregationApproach
- 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.