Package types

Examples of types.ClassificationInstance


      Object y = feats[feats.length - 1];
      for (int i = 3; i < feats.length - 1; i++) {
        if (feats[i].equals("1"))
          x.add(xAlphabet.lookupObject(i), 1.0);
      }
      result.add(new ClassificationInstance(xAlphabet, yAlphabet, x, y));
      ln = reader.readLine();
    }
    return result;
  }
View Full Code Here


        }
        reader.close();
        SparseVector x = new SparseVector();
        for (String w : words)
          x.add(xAlphabet.lookupObject(w), 1);
        result.add(new ClassificationInstance(xAlphabet, yAlphabet, x,
            label));
      }
    }
    return result;
  }
View Full Code Here

  private void updateW(double[] w, int bestFeature, double alpha,
      ArrayList<ClassificationInstance> trainingData) {
    double wrongUpdate = Math.exp(alpha);
    double correctUpdate = Math.exp(-alpha);
    for (int instInd = 0; instInd < trainingData.size(); instInd++) {
      ClassificationInstance inst = trainingData.get(instInd);
      for (int y = 0; y < yAlphabet.size(); y++) {
        SparseVector fv = fxy.apply(inst.x, y);
        for (int i = 0; i < fv.numEntries(); i++) {
          if (fv.getIndexAt(i) == bestFeature) {
            if (y == inst.y)
View Full Code Here

    for (int i = 0; i < correct.length; i++) {
      correct[i] = smooth;
      wrongs[i] = smooth;
    }
    for (int instInd = 0; instInd < trainingData.size(); instInd++) {
      ClassificationInstance inst = trainingData.get(instInd);
      total += w[instInd];
      for (int y = 0; y < yAlphabet.size(); y++) {
        SparseVector fv = fxy.apply(inst.x, y);
        if (y == inst.y) {
          for (int i = 0; i < fv.numEntries(); i++) {
View Full Code Here

        String tmpLab = label;
        if (r.nextDouble() < randomFrac)
          tmpLab = classes[r.nextInt(classes.length)];
        sv.add(xAlphabet.lookupObject(tmpLab + fInd), 1);
      }
      train.add(new ClassificationInstance(xAlphabet, yAlphabet, sv,
          label));
    }
    AdaBoost boost = new AdaBoost(10, xAlphabet, yAlphabet,
        new CompleteFeatureFunction(xAlphabet, yAlphabet));
    LinearClassifier h = boost.batchTrain(train);
View Full Code Here

TOP

Related Classes of types.ClassificationInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.