Package types

Examples of types.LinearClassifier


    System.out.println();
  }

  public LinearClassifier batchTrain(
      ArrayList<ClassificationInstance> trainingData) {
    LinearClassifier result = new LinearClassifier(xAlphabet, yAlphabet,
        fxy);
    double[] w = new double[trainingData.size()];
    for (int i = 0; i < w.length; i++)
      w[i] = 1.0 / trainingData.size();
    // choose $t$ weights.
View Full Code Here


      train.add(new ClassificationInstance(xAlphabet, yAlphabet, sv,
          label));
    }
    AdaBoost boost = new AdaBoost(10, xAlphabet, yAlphabet,
        new CompleteFeatureFunction(xAlphabet, yAlphabet));
    LinearClassifier h = boost.batchTrain(train);
    System.out.println(StaticUtils.computeAccuracy(h, train));
  }
View Full Code Here

  }

  public LinearClassifier batchTrain(
      ArrayList<ClassificationInstance> trainingData) {
    LinearClassifier w = new LinearClassifier(this.xAlphabet,
        this.yAlphabet, this.fxy);
    LinearClassifier theta = null;
    if (this.performAveraging) {
      theta = new LinearClassifier(this.xAlphabet, this.yAlphabet,
          this.fxy);
    }
    for (int iter = 0; iter < this.numIterations; iter++) {
      for (ClassificationInstance inst : trainingData) {
        int yhat = w.label(inst.x);
View Full Code Here

    ArrayList<ClassificationInstance> train = tmp[0];
    ArrayList<ClassificationInstance> test = tmp[1];
    Alphabet xA = allData.get(0).xAlphabet;
    Alphabet yA = allData.get(0).yAlphabet;
    System.out.println("num Features = " + allData.get(0).xAlphabet.size());
    LinearClassifier h;
    h = trainMaxEnt(train, xA, yA);
    // print out accuracy
    System.out.println("MaxEnt Train Accuracy = "
        + StaticUtils.computeAccuracy(h, train));
    System.out.println("MaxEnt Test  Accuracy = "
View Full Code Here

  public static LinearClassifier trainMaxEnt(
      ArrayList<ClassificationInstance> train, Alphabet xA, Alphabet yA) {
    MaxEntropy maxent = new MaxEntropy(10.0, xA, yA,
        new CompleteFeatureFunction(xA, yA));
    LinearClassifier h = maxent.batchTrain(train);
    return h;
  }
View Full Code Here

TOP

Related Classes of types.LinearClassifier

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.