Package types

Examples of types.LinearClassifier


  }

  public static LinearClassifier trainNaivBayes(
      ArrayList<ClassificationInstance> train, Alphabet xA, Alphabet yA) {
    NaiveBayes nb = new NaiveBayes(0.1, 0.1, xA, yA);
    LinearClassifier h = nb.batchTrain(train);
    return h;
  }
View Full Code Here


  public static LinearClassifier trainPerceptron(boolean doAveraging,
      int numIters, ArrayList<ClassificationInstance> train, Alphabet xA,
      Alphabet yA) {
    Perceptron p = new Perceptron(doAveraging, numIters, xA, yA,
        new CompleteFeatureFunction(xA, yA));
    LinearClassifier h = p.batchTrain(train);
    return h;
  }
View Full Code Here

      empiricalExpectations = new double[fxy.wSize()];
      for (ClassificationInstance inst : trainingData) {
        StaticUtils.plusEquals(empiricalExpectations, fxy.apply(inst.x,
            inst.y));
      }
      classifier = new LinearClassifier(xAlphabet, yAlphabet, fxy);
    }
View Full Code Here

    this.fxy = fxy;
  }

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

    return y * (fxy.defalutFeatureIndex + 1) + feat;
  }

  public LinearClassifier batchTrain(
      ArrayList<ClassificationInstance> trainingData) {
    LinearClassifier res = new LinearClassifier(xAlphabet, yAlphabet, fxy);
    int defaultFeatureIndex = fxy.defalutFeatureIndex;

    // update the counts that we've seen so far
    for (ClassificationInstance inst : trainingData) {
      counts[indexOf(inst.y, defaultFeatureIndex)] += 1;
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 = trainAdaBoost(50, train, xA, yA);
    System.out.println("Boost  Train Accuracy = "
        + StaticUtils.computeAccuracy(h, train));
    System.out.println("Boost  Test  Accuracy = "
        + StaticUtils.computeAccuracy(h, test));
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

  }

  public static LinearClassifier trainNaivBayes(
      ArrayList<ClassificationInstance> train, Alphabet xA, Alphabet yA) {
    NaiveBayes nb = new NaiveBayes(0.1, 0.1, xA, yA);
    LinearClassifier h = nb.batchTrain(train);
    return h;
  }
View Full Code Here

  public static LinearClassifier trainPerceptron(boolean doAveraging,
      int numIters, ArrayList<ClassificationInstance> train, Alphabet xA,
      Alphabet yA) {
    Perceptron p = new Perceptron(doAveraging, numIters, xA, yA,
        new CompleteFeatureFunction(xA, yA));
    LinearClassifier h = p.batchTrain(train);
    return h;
  }
View Full Code Here

  public static LinearClassifier trainAdaBoost(int numIters,
      ArrayList<ClassificationInstance> train, Alphabet xA, Alphabet yA) {
    AdaBoost b = new AdaBoost(numIters, xA, yA,
        new CompleteFeatureFunction(xA, yA));
    LinearClassifier h = b.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.