org.mymedialite.itemrec
Class KNN

java.lang.Object
  extended by org.mymedialite.itemrec.ItemRecommender
      extended by org.mymedialite.itemrec.KNN
All Implemented Interfaces:
java.lang.Cloneable, IRecommender
Direct Known Subclasses:
ItemKNN, UserKNN

public abstract class KNN
extends ItemRecommender

Base class for item recommenders that use some kind of kNN model.


Field Summary
protected  CorrelationMatrix correlation
          Correlation matrix over some kind of entity.
 int k
          The number of neighbors to take into account for prediction.
protected  int[][] nearest_neighbors
          Pre-computed nearest neighbors.
 
Fields inherited from class org.mymedialite.itemrec.ItemRecommender
feedback, maxItemID, maxUserID
 
Constructor Summary
KNN()
           
 
Method Summary
 void loadModel(java.io.BufferedReader reader)
          { @inheritDoc }
 void loadModel(java.lang.String filename)
          { @inheritDoc }
 void saveModel(java.io.PrintWriter writer)
          { @inheritDoc }
 void saveModel(java.lang.String filename)
          { @inheritDoc }
 
Methods inherited from class org.mymedialite.itemrec.ItemRecommender
canPredict, clone, getFeedback, predict, setFeedback, toString, train
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

k

public int k
The number of neighbors to take into account for prediction.


nearest_neighbors

protected int[][] nearest_neighbors
Pre-computed nearest neighbors.


correlation

protected CorrelationMatrix correlation
Correlation matrix over some kind of entity.

Constructor Detail

KNN

public KNN()
Method Detail

saveModel

public void saveModel(java.lang.String filename)
               throws java.io.IOException
{ @inheritDoc }

Specified by:
saveModel in interface IRecommender
Specified by:
saveModel in class ItemRecommender
Parameters:
filename - the file to write to
Throws:
java.io.IOException

saveModel

public void saveModel(java.io.PrintWriter writer)
{ @inheritDoc }

Specified by:
saveModel in class ItemRecommender

loadModel

public void loadModel(java.lang.String filename)
               throws java.io.IOException
{ @inheritDoc }

Specified by:
loadModel in interface IRecommender
Specified by:
loadModel in class ItemRecommender
Parameters:
filename - the file to read from
Throws:
java.io.IOException

loadModel

public void loadModel(java.io.BufferedReader reader)
               throws java.io.IOException
{ @inheritDoc }

Specified by:
loadModel in class ItemRecommender
Throws:
java.io.IOException