use of structures._RankItem in project IR_Base by Linda-sunshine.
the class WeightedAvgTransAdapt method constructNeighborhood.
@Override
public void constructNeighborhood(final SimType sType) {
super.constructNeighborhood(sType);
_CoLinAdaptStruct ui;
// the user's own similarity.
double sum;
// Normalize the similarity of neighbors.
for (int i = 0; i < m_userList.size(); i++) {
ui = (_CoLinAdaptStruct) m_userList.get(i);
sum = m_selfSim;
// Collect the sum of similarity.
for (_RankItem nit : ui.getNeighbors()) {
if (m_cosSim)
sum += nit.m_value;
else
sum++;
}
// Update the user's similarity.
ui.setSelfSim(m_selfSim / sum);
for (_RankItem nit : ui.getNeighbors()) {
if (m_cosSim)
nit.m_value /= sum;
else
nit.m_value = 1 / sum;
}
}
}
use of structures._RankItem in project IR_Base by Linda-sunshine.
the class asyncCoLinAdapt method gradientByR2.
@Override
protected void gradientByR2(_AdaptStruct user) {
_CoLinAdaptStruct uj, ui = (_CoLinAdaptStruct) user;
for (_RankItem nit : ui.getNeighbors()) {
uj = (_CoLinAdaptStruct) m_userList.get(nit.m_index);
gradientByR2(ui, uj, nit.m_value);
}
for (_RankItem nit : ui.getReverseNeighbors()) {
uj = (_CoLinAdaptStruct) m_userList.get(nit.m_index);
gradientByR2(ui, uj, nit.m_value);
}
}
use of structures._RankItem in project IR_Base by Linda-sunshine.
the class asyncCoLinAdaptFirstOrder method gradientByRelatedR1.
// compute gradient for all related user in first order connection (exclude itself)
void gradientByRelatedR1(_CoLinAdaptStruct ui) {
_CoLinAdaptStruct uj;
for (_RankItem nit : ui.getNeighbors()) {
uj = (_CoLinAdaptStruct) m_userList.get(nit.m_index);
gradientByR1(uj);
}
for (_RankItem nit : ui.getReverseNeighbors()) {
uj = (_CoLinAdaptStruct) m_userList.get(nit.m_index);
gradientByR1(uj);
}
}
use of structures._RankItem in project IR_Base by Linda-sunshine.
the class asyncCoLinAdaptFirstOrder method gradientDescent.
@Override
void gradientDescent(_CoLinAdaptStruct ui, double initStepSize, double inc) {
// update the current user
super.gradientDescent(ui, initStepSize, inc);
_CoLinAdaptStruct uj;
for (_RankItem nit : ui.getNeighbors()) {
uj = (_CoLinAdaptStruct) m_userList.get(nit.m_index);
super.gradientDescent(uj, initStepSize, inc / 3);
}
for (_RankItem nit : ui.getReverseNeighbors()) {
uj = (_CoLinAdaptStruct) m_userList.get(nit.m_index);
super.gradientDescent(uj, initStepSize, inc / 3);
}
}
use of structures._RankItem in project IR_Base by Linda-sunshine.
the class CLRWithDP method printTopWords.
void printTopWords(_thetaStar cluster) {
MyPriorityQueue<_RankItem> wordRanker = new MyPriorityQueue<_RankItem>(10);
double[] phi = cluster.getModel();
// we will skip the bias term!
System.out.format("Cluster %d (%d)\n[positive]: ", cluster.getIndex(), cluster.getMemSize());
for (int i = 1; i < phi.length; i++) // top positive words with expected polarity
wordRanker.add(new _RankItem(i, phi[i]));
for (_RankItem it : wordRanker) System.out.format("%s:%.3f\t", m_features[it.m_index], phi[it.m_index]);
System.out.format("\n[negative]: ");
wordRanker.clear();
for (int i = 1; i < phi.length; i++) // top negative words
wordRanker.add(new _RankItem(i, -phi[i]));
for (_RankItem it : wordRanker) System.out.format("%s:%.3f\t", m_features[it.m_index], phi[it.m_index]);
}
Aggregations