|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjcolibri.extensions.recommendation.collaborative.MatrixCaseBase
public abstract class MatrixCaseBase
Specific implementation of CBRCaseBase to allow collaborative recommendations.
These kind of recommendations are based in the past experieces of other users.
This case base manages cases composed by a description, a solution and a result.
The description usually contains the information about the user that made the recommendation,
the solution contains the information about the recommended item, and the
result stores the rating value for the item (the value that the user assigns to an item after evaluating it).
This way, this case base implementation stores cases as a table:
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.
PearsonMatrixCaseBase
,
MoviesRecommender
Nested Class Summary | |
---|---|
class |
MatrixCaseBase.RatingTuple
Stores a rating for an item. |
class |
MatrixCaseBase.SimilarTuple
Stores the similarity among neighbors. |
Constructor Summary | |
---|---|
MatrixCaseBase(Attribute value)
Constructor. |
Method Summary | |
---|---|
void |
close()
Closes the case base |
protected abstract void |
computeSimilarities()
Computes the similarity of neighbors (each neighbor is defined by the description) |
void |
forgetCases(java.util.Collection<CBRCase> cases)
Forgets cases. |
java.util.Collection<CBRCase> |
getCases()
Returns the stored cases |
java.util.Collection<CBRCase> |
getCases(CaseBaseFilter filter)
Returns selected cases. |
CaseComponent |
getDescription(java.lang.Integer id)
Utility method to obtain the description object given its id. |
java.util.Set<java.lang.Integer> |
getDescriptions()
Utility method to obtain all the descriptions stored in this case base |
java.util.Collection<MatrixCaseBase.RatingTuple> |
getRatingTuples(int descriptionId)
Returns the ratings that a user has done. |
abstract double |
getSimil(java.lang.Integer id1,
java.lang.Integer id2)
Returns the similarity of two neighbors. |
abstract java.util.Collection<MatrixCaseBase.SimilarTuple> |
getSimilar(java.lang.Integer id)
Returns the list of similar neighbors for a given one |
CaseComponent |
getSolution(java.lang.Integer id)
Utility method to obtain the solution object given its id. |
java.util.Set<java.lang.Integer> |
getSolutions()
Utility method to obtain all the solutions stored in this case base |
void |
init(Connector connector)
Initializes the case base. |
void |
learnCases(java.util.Collection<CBRCase> cases)
Adds new cases to the case base, reorganizing the cases base and re-computing neighbors similarities. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MatrixCaseBase(Attribute value)
value
- Method Detail |
---|
protected abstract void computeSimilarities()
public abstract double getSimil(java.lang.Integer id1, java.lang.Integer id2)
id1
- of the first neighborid2
- of the second neighbor.
public abstract java.util.Collection<MatrixCaseBase.SimilarTuple> getSimilar(java.lang.Integer id)
id
- of the neighbor
public void init(Connector connector)
init
in interface CBRCaseBase
public CaseComponent getDescription(java.lang.Integer id)
id
- of the description object
public java.util.Set<java.lang.Integer> getDescriptions()
public CaseComponent getSolution(java.lang.Integer id)
id
- of the solution object
public java.util.Set<java.lang.Integer> getSolutions()
public java.util.Collection<MatrixCaseBase.RatingTuple> getRatingTuples(int descriptionId)
descriptionId
- of the user
public void close()
close
in interface CBRCaseBase
public void forgetCases(java.util.Collection<CBRCase> cases)
forgetCases
in interface CBRCaseBase
cases
- to be removedpublic java.util.Collection<CBRCase> getCases()
getCases
in interface CBRCaseBase
public java.util.Collection<CBRCase> getCases(CaseBaseFilter filter)
getCases
in interface CBRCaseBase
filter
- a case base filter
public void learnCases(java.util.Collection<CBRCase> cases)
learnCases
in interface CBRCaseBase
cases
- to be added
|
GAIA - Group for Artificial Intelligence Applications http://gaia.fdi.ucm.es |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |