Search in sources :

Example 21 with structures._RankItem

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;
        }
    }
}
Also used : structures._RankItem(structures._RankItem)

Example 22 with structures._RankItem

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);
    }
}
Also used : structures._RankItem(structures._RankItem)

Example 23 with structures._RankItem

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);
    }
}
Also used : structures._RankItem(structures._RankItem)

Example 24 with structures._RankItem

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);
    }
}
Also used : structures._RankItem(structures._RankItem)

Example 25 with structures._RankItem

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]);
}
Also used : structures._RankItem(structures._RankItem) MyPriorityQueue(structures.MyPriorityQueue)

Aggregations

structures._RankItem (structures._RankItem)66 MyPriorityQueue (structures.MyPriorityQueue)39 File (java.io.File)27 PrintWriter (java.io.PrintWriter)27 structures._Doc (structures._Doc)25 FileNotFoundException (java.io.FileNotFoundException)20 structures._ParentDoc4DCM (structures._ParentDoc4DCM)3 structures._Review (structures._Review)3 structures._SparseFeature (structures._SparseFeature)3 structures._stat (structures._stat)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 structures._Doc4DCMLDA (structures._Doc4DCMLDA)2 SparseDoubleMatrix2D (cern.colt.matrix.tdouble.impl.SparseDoubleMatrix2D)1 structures._HDPThetaStar (structures._HDPThetaStar)1 structures._Node (structures._Node)1 structures._QUPair (structures._QUPair)1 structures._Query (structures._Query)1 structures._Stn (structures._Stn)1 structures._thetaStar (structures._thetaStar)1