public abstract class MatrixCaseBase extends Object implements es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCaseBase
| Item1 | Item2 | Item3 | Item4 | Item5 | ... | ItemM | |
| User1 | rating12 | rating14 | |||||
| User2 | rating21 | rating23 | rating2N | ||||
| User3 | rating33 | rating34 | rating3N | ||||
| ... | |||||||
| UserN | ratingN2 | ratingN5 | ratingNN |
Collaborative recommenders can be separated into three steps:
To allow an efficient comparison, ratings must be sorted by neighbors. In the above table this means that cases are organized by rows. And that is done internally in this class through the organizeByDescriptionId() method. Then, the ratings of each user can be accessed through the getRatingTuples() method. A RatingTuple object stores the id of the item and its rating (id of the solution and id of the result).
There are also 2 internal classes (CommonRatingTuple and CommonRatingsIterator) that allow to obtain efficiently the common ratings of two users. This will be used by subclasses when computing the neighbors similarity. The code of these classes is an adaptation of the one developed by Jerome Kelleher and Derek Bridge for the Collaborative Movie Recommender project at University College Cork (Ireland).
Recommender 12 shows how to use these classes.
| Modifier and Type | Class and Description |
|---|---|
class |
MatrixCaseBase.RatingTuple
Stores a rating for an item.
|
class |
MatrixCaseBase.SimilarTuple
Stores the similarity among neighbors.
|
| Constructor and Description |
|---|
MatrixCaseBase(es.ucm.fdi.gaia.jcolibri.cbrcore.Attribute value)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the case base
|
protected abstract void |
computeSimilarities()
Computes the similarity of neighbors (each neighbor is defined by the description)
|
void |
forgetCases(Collection<es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase> cases)
Forgets cases.
|
Collection<es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase> |
getCases()
Returns the stored cases
|
Collection<es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase> |
getCases(es.ucm.fdi.gaia.jcolibri.cbrcore.CaseBaseFilter filter)
Returns selected cases.
|
es.ucm.fdi.gaia.jcolibri.cbrcore.CaseComponent |
getDescription(Integer id)
Utility method to obtain the description object given its id.
|
Set<Integer> |
getDescriptions()
Utility method to obtain all the descriptions stored in this case base
|
Collection<MatrixCaseBase.RatingTuple> |
getRatingTuples(int descriptionId)
Returns the ratings that a user has done.
|
abstract double |
getSimil(Integer id1,
Integer id2)
Returns the similarity of two neighbors.
|
abstract Collection<MatrixCaseBase.SimilarTuple> |
getSimilar(Integer id)
Returns the list of similar neighbors for a given one
|
es.ucm.fdi.gaia.jcolibri.cbrcore.CaseComponent |
getSolution(Integer id)
Utility method to obtain the solution object given its id.
|
Set<Integer> |
getSolutions()
Utility method to obtain all the solutions stored in this case base
|
void |
init(es.ucm.fdi.gaia.jcolibri.cbrcore.Connector connector)
Initializes the case base.
|
void |
learnCases(Collection<es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase> cases)
Adds new cases to the case base, reorganizing the cases base and re-computing neighbors similarities.
|
public MatrixCaseBase(es.ucm.fdi.gaia.jcolibri.cbrcore.Attribute value)
value - protected abstract void computeSimilarities()
public abstract double getSimil(Integer id1, Integer id2)
id1 - of the first neighborid2 - of the second neighbor.public abstract Collection<MatrixCaseBase.SimilarTuple> getSimilar(Integer id)
id - of the neighborpublic void init(es.ucm.fdi.gaia.jcolibri.cbrcore.Connector connector)
init in interface es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCaseBasepublic es.ucm.fdi.gaia.jcolibri.cbrcore.CaseComponent getDescription(Integer id)
id - of the description objectpublic Set<Integer> getDescriptions()
public es.ucm.fdi.gaia.jcolibri.cbrcore.CaseComponent getSolution(Integer id)
id - of the solution objectpublic Set<Integer> getSolutions()
public Collection<MatrixCaseBase.RatingTuple> getRatingTuples(int descriptionId)
descriptionId - of the userpublic void close()
close in interface es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCaseBasepublic void forgetCases(Collection<es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase> cases)
forgetCases in interface es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCaseBasepublic Collection<es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase> getCases()
getCases in interface es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCaseBasepublic Collection<es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase> getCases(es.ucm.fdi.gaia.jcolibri.cbrcore.CaseBaseFilter filter)
getCases in interface es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCaseBasepublic void learnCases(Collection<es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase> cases)
learnCases in interface es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCaseBaseCopyright © 2018 Group of Artificial Intelligence Applications (GAIA). All rights reserved.