guoguibing / librec

LibRec: A Leading Java Library for Recommender Systems, see
https://www.librec.net/
Other
3.23k stars 1.03k forks source link

Error, return zero for all userCode, itemCode and rating values! #265

Closed sososa1213 closed 6 years ago

sososa1213 commented 6 years ago

I need to retrieve values of userCode, itemCode and rating from "/movielens/ml-100k/ratings.txt". I use this way

Resource resource = new Resource("librec.properties");
Configuration conf = new Configuration();
conf.addResource(resource);
Randoms.seed(1);
TextDataModel dataModel = new TextDataModel(conf);
dataModel.buildDataModel();
SparseMatrix trainMatrix = dataModel.getDataSplitter().getTrainData();
int count = trainMatrix.numRows();
 for (int i : trainMatrix.rows()) {
            int userCode = (int) trainMatrix.get(i,0);
        int itemCode = (int) trainMatrix.get(i, 1);
        double rating = trainMatrix.get(i, 2);
}

when I print values is zero. Any help to fix this error