If I use this method is that mean I used Sparse Matrix?
Do I need transform the raw data into the sparse matrix and store it in the 'recommender' object or already the librec do that?
I have to figure this out before continue write the rest of the code.
What I am trying to do is to find values of userCode ,itemCode and rating by using sparse matrix.
Resource resource = new Resource("librec.properties");
Configuration conf = new Configuration();
conf.addResource(resource);
conf.set("data.splitter.trainset.ratio", "0.8");
conf.set("inputDataPath", conf.get("dfs.data.dir") + "/movielens/ml-100k/ratings.txt");
conf.set("data.column.format","UIRT");
conf.set("data.convert.binarize.threshold","-1.0");
TextDataModel dataModel = new TextDataModel(conf);
try {
dataModel.buildDataModel();
} catch (LibrecException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
RecommenderContext context = new RecommenderContext(conf,dataModel);
RecommenderSimilarity similarity = new PCCSimilarity();
similarity.buildSimilarityMatrix(dataModel);
context.setSimilarity(similarity);
Recommender recommender = new ItemKNNRecommender();
recommender.setContext(context);
try {
recommender.recommend(context);
} catch (LibrecException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
java.util.List<RecommendedItem> recommendedItemList = recommender.getRecommendedList();
for (RecommendedItem recommendedItem : recommendedItemList) {
int userCode = Integer.parseInt(recommendedItem.getUserId());
int itemCode = Integer.parseInt(recommendedItem.getItemId());
double rating = recommendedItem.getValue();
}
If I use this method is that mean I used Sparse Matrix? Do I need transform the raw data into the sparse matrix and store it in the 'recommender' object or already the librec do that?
I have to figure this out before continue write the rest of the code.
What I am trying to do is to find values of userCode ,itemCode and rating by using sparse matrix.
@allenjack