use of structures._thetaStar in project IR_Base by Linda-sunshine.
the class CLRWithDP method printInfo.
public void printInfo() {
MyPriorityQueue<_RankItem> clusterRanker = new MyPriorityQueue<_RankItem>(5);
// clear the statistics
for (int i = 0; i < m_kBar; i++) {
m_thetaStars[i].resetCount();
clusterRanker.add(new _RankItem(i, m_thetaStars[i].getMemSize()));
}
// collect statistics across users in adaptation data
_thetaStar theta = null;
for (int i = 0; i < m_userList.size(); i++) {
_DPAdaptStruct user = (_DPAdaptStruct) m_userList.get(i);
theta = user.getThetaStar();
for (_Review review : user.getReviews()) {
if (review.getType() != rType.ADAPTATION)
// only touch the adaptation data
continue;
else if (review.getYLabel() == 1)
theta.incPosCount();
else
theta.incNegCount();
}
}
System.out.print("[Info]Clusters:");
for (int i = 0; i < m_kBar; i++) System.out.format("%s\t", m_thetaStars[i].showStat());
System.out.print(String.format("\n[Info]%d Clusters are found in total!\n", m_kBar));
}
use of structures._thetaStar in project IR_Base by Linda-sunshine.
the class CLRWithDP method swapTheta.
protected void swapTheta(int a, int b) {
_thetaStar cTheta = m_thetaStars[a];
m_thetaStars[a] = m_thetaStars[b];
// kBar starts from 0, the size decides how many are valid.
m_thetaStars[b] = cTheta;
}
use of structures._thetaStar in project IR_Base by Linda-sunshine.
the class CLRWithDP method saveClusterModels.
public void saveClusterModels(String model) {
PrintWriter writer;
String filename;
File dir = new File(model);
_thetaStar theta;
double[] weight;
try {
if (!dir.exists())
dir.mkdirs();
for (int i = 0; i < m_kBar; i++) {
theta = m_thetaStars[i];
filename = String.format("%s/%d.classifier", model, theta.getIndex());
writer = new PrintWriter(new File(filename));
weight = theta.getModel();
for (int v = 0; v < weight.length; v++) {
if (v == weight.length - 1)
writer.write(Double.toString(weight[v]));
else
writer.write(weight[v] + ",");
}
writer.close();
}
writer = new PrintWriter(new File(model + "/ClusterMember.txt"));
for (_AdaptStruct u : m_userList) {
_DPAdaptStruct user = (_DPAdaptStruct) u;
writer.write(user.getUserID() + "\t" + user.getThetaStar().getIndex() + "\n");
}
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations