Search in sources :

Example 6 with FeatureNode

use of Classifier.supervised.liblinear.FeatureNode in project IR_Base by Linda-sunshine.

the class Utils method createLibLinearFV.

public static Feature[] createLibLinearFV(HashMap<Integer, Double> spVct) {
    Feature[] node = new Feature[spVct.size()];
    int fid = 0;
    for (_SparseFeature fv : createSpVct(spVct)) // svm's feature index starts from 1
    node[fid++] = new FeatureNode(1 + fv.getIndex(), fv.getValue());
    return node;
}
Also used : FeatureNode(Classifier.supervised.liblinear.FeatureNode) structures._SparseFeature(structures._SparseFeature) Feature(Classifier.supervised.liblinear.Feature) structures._SparseFeature(structures._SparseFeature)

Example 7 with FeatureNode

use of Classifier.supervised.liblinear.FeatureNode in project IR_Base by Linda-sunshine.

the class Utils method createLibLinearFV.

public static Feature[] createLibLinearFV(_SparseFeature[] spVct, int fSize) {
    Feature[] node;
    if (// include bias term in the end
    fSize > 0)
        node = new Feature[1 + spVct.length];
    else
        // ignore bias term
        node = new Feature[spVct.length];
    int fid = 0;
    for (_SparseFeature fv : spVct) // svm's feature index starts from 1
    node[fid++] = new FeatureNode(1 + fv.getIndex(), fv.getValue());
    if (fSize > 0)
        node[fid] = new FeatureNode(1 + fSize, 1.0);
    return node;
}
Also used : FeatureNode(Classifier.supervised.liblinear.FeatureNode) structures._SparseFeature(structures._SparseFeature) Feature(Classifier.supervised.liblinear.Feature) structures._SparseFeature(structures._SparseFeature)

Aggregations

Feature (Classifier.supervised.liblinear.Feature)7 FeatureNode (Classifier.supervised.liblinear.FeatureNode)7 structures._SparseFeature (structures._SparseFeature)7 Model (Classifier.supervised.liblinear.Model)1 Parameter (Classifier.supervised.liblinear.Parameter)1 Problem (Classifier.supervised.liblinear.Problem)1 SolverType (Classifier.supervised.liblinear.SolverType)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 structures._ChildDoc (structures._ChildDoc)1 structures._Word (structures._Word)1