public class DataDAO
extends java.lang.Object
Constructor and Description |
---|
DataDAO(java.lang.String path)
Contructor for data DAO object
|
DataDAO(java.lang.String path,
com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> userIds)
Contructor for data DAO object
|
DataDAO(java.lang.String path,
com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> userIds,
com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> itemIds)
Constructor for a data DAO object
|
Modifier and Type | Method and Description |
---|---|
void |
convert(java.lang.String sep,
java.lang.String toSep)
Convert a data file separated by
sep to a data file separated by
toSep |
java.lang.String |
getDataPath() |
java.lang.String |
getItemId(int innerId) |
int |
getItemId(java.lang.String rawId) |
com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> |
getItemIds() |
SparseMatrix |
getRateMatrix() |
java.util.List<java.lang.Double> |
getScales() |
java.lang.String |
getUserId(int innerId) |
int |
getUserId(java.lang.String rawId) |
com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> |
getUserIds() |
boolean |
isItemAsUser() |
int |
numItems() |
int |
numRates() |
int |
numUsers() |
void |
printSpecs()
print out specifications of the dataset
|
SparseMatrix |
readData()
Default relevant columns {0: user column, 1: item column, 2: rate
column}; otherwise try
readData(int[] rels) |
SparseMatrix |
readData(boolean isCCSUsed) |
SparseMatrix |
readData(int[] cols,
boolean isCCSUsed)
Read data from the data file
|
void |
writeArff(java.lang.String relation,
java.lang.String toPath)
Write rate matrix to a data file with format ".arff" which can be used by
the PREA toolkit
|
void |
writeData(java.lang.String toPath)
Default sep=" " is adopted
|
void |
writeData(java.lang.String toPath,
java.lang.String sep)
write the rate data to another data file given by the path
toPath |
public DataDAO(java.lang.String path, com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> userIds, com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> itemIds)
path
- path to data fileuserIds
- user: {raw id, inner id} mapitemIds
- item: {raw id, inner id} mappublic DataDAO(java.lang.String path)
path
- path to data filepublic DataDAO(java.lang.String path, com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> userIds)
public void convert(java.lang.String sep, java.lang.String toSep) throws java.lang.Exception
sep
to a data file separated by
toSep
sep
- separator of the source filetoSep
- separtor of the target filejava.lang.Exception
public SparseMatrix readData() throws java.lang.Exception
readData(int[] rels)
java.lang.Exception
public SparseMatrix readData(boolean isCCSUsed) throws java.lang.Exception
isCCSUsed
- whether to construct CCS structures while reading datajava.lang.Exception
public SparseMatrix readData(int[] cols, boolean isCCSUsed) throws java.lang.Exception
cols
- the indexes of the relevant columns in the data fileisCCSUsed
- whether to store the CCS structures of the rating matrixjava.lang.Exception
public void writeData(java.lang.String toPath, java.lang.String sep) throws java.lang.Exception
toPath
toPath
- the data file to write tosep
- the sparator of the written data filejava.lang.Exception
public void writeData(java.lang.String toPath) throws java.lang.Exception
java.lang.Exception
public void writeArff(java.lang.String relation, java.lang.String toPath) throws java.lang.Exception
relation
- relation name of datasettoPath
- data file pathjava.lang.Exception
public void printSpecs() throws java.lang.Exception
java.lang.Exception
public int numUsers()
public int numItems()
public int numRates()
public int getUserId(java.lang.String rawId)
rawId
- raw user id as Stringpublic java.lang.String getUserId(int innerId)
innerId
- inner user id as intpublic int getItemId(java.lang.String rawId)
rawId
- raw item id as Stringpublic java.lang.String getItemId(int innerId)
innerId
- inner user id as intpublic java.lang.String getDataPath()
public SparseMatrix getRateMatrix()
public boolean isItemAsUser()
public java.util.List<java.lang.Double> getScales()
public com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> getUserIds()
public com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> getItemIds()