public class DataSplitter
extends java.lang.Object
Constructor and Description |
---|
DataSplitter(SparseMatrix rateMatrix)
Construct a data splitter with data source of a given rate matrix
|
DataSplitter(SparseMatrix rateMatrix,
int kfold)
Construct a data splitter to split a given matrix into kfolds
|
Modifier and Type | Method and Description |
---|---|
SparseMatrix[] |
getDataView(java.lang.String view) |
SparseMatrix[] |
getGiven(double ratio)
Split ratings into two parts: the training set consisting of user-item
ratings where
numGiven ratings are preserved for each user, and
the rest are used as the testing data |
SparseMatrix[] |
getGiven(int numGiven)
Split ratings into two parts: the training set consisting of user-item
ratings where
numGiven ratings are preserved for each user, and
the rest are used as the testing data |
SparseMatrix[] |
getKthFold(int k)
Return the k-th fold as test set (testMatrix), making all the others as
train set in rateMatrix.
|
SparseMatrix[] |
getRatio(double ratio)
Split ratings into two parts: (1-ratio) training, (ratio) testing data
|
void |
getSample(int numUsers,
int numItems)
generate a random sample of rate matrix with specified number of users
and items
|
public DataSplitter(SparseMatrix rateMatrix, int kfold)
rateMatrix
- data matrixkfold
- number of folds to splitpublic DataSplitter(SparseMatrix rateMatrix)
rateMatrix
- data sourcepublic SparseMatrix[] getRatio(double ratio)
ratio
- the ratio of training data over all the ratings.public SparseMatrix[] getGiven(int numGiven) throws java.lang.Exception
numGiven
ratings are preserved for each user, and
the rest are used as the testing datanumGiven
- the number of ratings given to each userjava.lang.Exception
public SparseMatrix[] getGiven(double ratio) throws java.lang.Exception
numGiven
ratings are preserved for each user, and
the rest are used as the testing datanumGiven
- the number of ratings given to each userjava.lang.Exception
public void getSample(int numUsers, int numItems) throws java.lang.Exception
numUsers
- number of users, -1 to use all users;numItems
- number of items, -1 to user all items;java.lang.Exception
public SparseMatrix[] getDataView(java.lang.String view)
public SparseMatrix[] getKthFold(int k)
k
- The index for desired fold.