use of org.haiku.haikudepotserver.dataobjects.auto._User in project IR_Base by Linda-sunshine.
the class MultiThreadedNetworkAnalyzer method sampleUsers4ColdStart4Edges.
// reserve edges for link prediction, group users based on document size
// d1 and d2 are thresholds for splitting users into light, medium and heavy users
public void sampleUsers4ColdStart4Edges(String dir, int d1, int d2, int sampleSize) {
Random rand = new Random();
ArrayList<String> light = new ArrayList<>();
ArrayList<String> medium = new ArrayList<>();
ArrayList<String> heavy = new ArrayList<>();
// step 1: collect all the user ids in different groups
for (_User user : m_users) {
if (user.getReviews() == null)
continue;
String userId = user.getUserID();
int rvwSize = user.getReviews().size();
if (rvwSize > d2) {
heavy.add(userId);
} else if (rvwSize > d1) {
medium.add(userId);
} else
light.add(userId);
}
// step 2: sample specified number of users from each group
HashSet<String> sampledLight = sample(light, sampleSize);
HashSet<String> sampledMedium = sample(medium, sampleSize);
HashSet<String> sampledHeavy = sample(heavy, sampleSize);
// step 3: since edges are symmetric, remove the associated edges
removeSymmetricEdges(sampledLight);
removeSymmetricEdges(sampledMedium);
removeSymmetricEdges(sampledHeavy);
// step 4: save the sampled users and their interactions
writeCVIndex4Edges(dir + "_interactions.txt", sampledLight, sampledMedium, sampledHeavy);
// step 5: sample non-interactions for different groups of users
for (int time : new int[] { 2, 3, 4, 5, 6, 7, 8 }) {
String filename = String.format("%s_noninteractions_time_%d_light.txt", dir, time);
sampleNonInteractions4OneGroup(filename, sampledLight, time);
filename = String.format("%s_noninteractions_time_%d_medium.txt", dir, time);
sampleNonInteractions4OneGroup(filename, sampledMedium, time);
filename = String.format("%s_noninteractions_time_%d_heavy.txt", dir, time);
sampleNonInteractions4OneGroup(filename, sampledHeavy, time);
}
}
use of org.haiku.haikudepotserver.dataobjects.auto._User in project IR_Base by Linda-sunshine.
the class CLRWithMMB method loadUsers.
@Override
public void loadUsers(ArrayList<_User> userList) {
m_userList = new ArrayList<_AdaptStruct>();
for (_User user : userList) m_userList.add(new _MMBAdaptStruct(user));
m_pWeights = new double[m_gWeights.length];
m_indicator = new _HDPThetaStar[m_userList.size()][m_userList.size()];
}
use of org.haiku.haikudepotserver.dataobjects.auto._User in project IR_Base by Linda-sunshine.
the class CLinAdaptWithKmeans method loadUsers.
// Initialize the weights of the transformation matrix.
@Override
public void loadUsers(ArrayList<_User> userList) {
int totalUserSize = userList.size();
// 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 _CLinAdaptStruct(user, m_dim, i, totalUserSize, m_clusterSize));
}
m_pWeights = new double[m_gWeights.length];
// step1: init the shared A: individual + cluster + global
_CLinAdaptStruct.sharedA = new double[getVSize()];
for (int i = 0; i < m_userList.size() + m_clusterSize; i++) {
for (int j = 0; j < m_dim; j++) {
_CLinAdaptStruct.sharedA[i * m_dim * 2 + j] = 1;
}
}
}
use of org.haiku.haikudepotserver.dataobjects.auto._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 org.haiku.haikudepotserver.dataobjects.auto._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