use of com.model._User in project IR_Base by Linda-sunshine.
the class UserAnalyzer method loadSVDFile.
// Added by Lin: Load the svd file to get the low dim representation of users.
public void loadSVDFile(String filename) {
try {
// Construct the <userID, user> map first.
int count = 0;
HashMap<String, double[]> IDLowDimMap = new HashMap<String, double[]>();
int skip = 3;
File file = new File(filename);
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
String line, userID;
String[] strs;
double[] lowDims;
// Skip the first three lines.
while (skip-- > 0) reader.readLine();
while ((line = reader.readLine()) != null) {
strs = line.split("\\s+");
userID = strs[0];
lowDims = new double[strs.length - 1];
for (int i = 1; i < strs.length; i++) lowDims[i - 1] = Double.valueOf(strs[i]);
IDLowDimMap.put(userID, lowDims);
count++;
}
// Currently, there are missing low dimension representation of users.
for (_User u : m_users) {
if (IDLowDimMap.containsKey(u.getUserID()))
u.setLowDimProfile(IDLowDimMap.get(u.getUserID()));
else {
System.out.println("[Warning]" + u.getUserID() + " : low dim profile missing.");
u.setLowDimProfile(new double[11]);
}
}
reader.close();
System.out.format("Ther are %d users and %d users' low dimension profile are loaded.\n", m_users.size(), count);
} catch (IOException e) {
e.printStackTrace();
}
}
use of com.model._User in project IR_Base by Linda-sunshine.
the class IndividualSVM method loadSuperUsers.
public void loadSuperUsers(ArrayList<_User> userList) {
m_supUserList = new ArrayList<_AdaptStruct>();
for (_User user : userList) m_supUserList.add(new _AdaptStruct(user));
m_pWeights = new double[m_featureSize + 1];
}
use of com.model._User in project IR_Base by Linda-sunshine.
the class CoLinAdaptWithDiffFeatureGroups method constructUserList.
@Override
void constructUserList(ArrayList<_User> userList) {
int ASize = 2 * m_dimA;
int BSize = 2 * m_dimB;
// step 1: create space
m_userList = new ArrayList<_AdaptStruct>();
for (int i = 0; i < userList.size(); i++) {
_User user = userList.get(i);
m_userList.add(new _CoLinAdaptDiffFvGroupsStruct(user, m_dimA, i, m_topK, m_dimB));
}
m_pWeights = new double[m_gWeights.length];
// huge space consumption
_CoLinAdaptDiffFvGroupsStruct.sharedA = new double[getASize()];
_CoLinAdaptDiffFvGroupsStruct.sharedB = new double[getBSize()];
// step 2: copy each user's A and B to shared A and B in _CoLinAdaptStruct
_CoLinAdaptDiffFvGroupsStruct user;
for (int i = 0; i < m_userList.size(); i++) {
user = (_CoLinAdaptDiffFvGroupsStruct) m_userList.get(i);
System.arraycopy(user.m_A, 0, _CoLinAdaptDiffFvGroupsStruct.sharedA, ASize * i, ASize);
System.arraycopy(user.m_B, 0, _CoLinAdaptDiffFvGroupsStruct.sharedB, BSize * i, BSize);
}
}
use of com.model._User in project IR_Base by Linda-sunshine.
the class LinAdapt method loadUsers.
// Initialize the weights of the transformation matrix.
@Override
public void loadUsers(ArrayList<_User> userList) {
m_userList = new ArrayList<_AdaptStruct>();
for (_User user : userList) m_userList.add(new _LinAdaptStruct(user, m_dim));
m_pWeights = new double[m_gWeights.length];
}
use of com.model._User in project IR_Base by Linda-sunshine.
the class WeightedAvgAdapt method constructUserList.
@Override
void constructUserList(ArrayList<_User> userList) {
int vSize = m_dim;
// step 1: create space
m_userList = new ArrayList<_AdaptStruct>();
for (int i = 0; i < userList.size(); i++) {
_User user = userList.get(i);
// we will not create transformation matrix for this user
m_userList.add(new _CoLinAdaptStruct(user, -1, i, m_topK));
// Initiate user weights with global weights.
user.setModel(m_gWeights);
}
m_pWeights = new double[m_gWeights.length];
// huge space consumption
_CoLinAdaptStruct.sharedA = new double[getVSize()];
// step 2: copy each user's weights to shared A(weights) in _CoLinAdaptStruct
for (int i = 0; i < m_userList.size(); i++) System.arraycopy(m_gWeights, 0, _CoLinAdaptStruct.sharedA, vSize * i, vSize);
}
Aggregations