Package org.fnlp.ml.classifier.linear

Examples of org.fnlp.ml.classifier.linear.OnlineTrainer


    } else {
      inference = new HigherOrderViterbi(templets, labels.size());
      update = new HigherOrderViterbiPAUpdate(templets, labels.size(), true);
    }

    OnlineTrainer trainer;

    if(cl!=null){
      trainer = new OnlineTrainer(cl, update, loss, features.size(),iterNum, c);
    }else{
      trainer = new OnlineTrainer(inference, update, loss,
          features.size(), iterNum, c);
    }

    cl = trainer.train(trainSet, testSet);

    if(cl!=null&&newmodel!=null)
      saveTo(newmodel);
    else
      saveTo(model);
View Full Code Here


    instset.loadThruStagePipes(reader);

    /**
     * 建立分类器
     */   
    OnlineTrainer trainer = new OnlineTrainer(af,100);
    trainer.c = 0.01f;
    pclassifier = trainer.train(instset);
    pp.removeTargetPipe();
    pclassifier.setPipe(pp);
    af.setStopIncrement(true);

    //将分类器保存到模型文件
View Full Code Here

      instset.loadThruStagePipes(new SimpleFileReader(trainFile," ",true,Type.LabelData));
      Generator gen = new SFGenerator();
      ZeroOneLoss l = new ZeroOneLoss();
      Inferencer ms = new LinearMax(gen, factory.getLabelSize());
      Update update = new LinearMaxPAUpdate(l);
      OnlineTrainer trainer = new OnlineTrainer(ms, update,l, factory.getFeatureSize(), 50,0.005f);
      Linear pclassifier = trainer.train(instset,instset);
      pipe.removeTargetPipe();
      pclassifier.setPipe(pipe);
      factory.setStopIncrement(true);
      pclassifier.saveTo(modelFile);
    }
View Full Code Here

    HammingLoss loss = new HammingLoss();
    Inferencer inference = new LinearViterbi(templets, labels.size());
    Update update = new LinearViterbiPAUpdate((LinearViterbi) inference, loss);


    OnlineTrainer trainer = new OnlineTrainer(inference, update, loss,
        features.size(), 50,0.1f);

    Linear cl = trainer.train(trainSet);


    // test data没有标注
    Pipe tpipe = featurePipe;
    // 测试集
View Full Code Here

    ZeroOneLoss loss = new ZeroOneLoss();
    LinearMaxPAUpdate update = new LinearMaxPAUpdate(loss);
   
   
    Inferencer msolver = new LinearMax(featureGen, al.size() );
    OnlineTrainer trainer = new OnlineTrainer(msolver, update, loss, af.size(), round,
        c);

    Linear classify = trainer.train(train, test);
    String modelFile = path+".m.gz";
    classify.saveTo(modelFile);

    long end = System.currentTimeMillis();
    System.out.println("Total Time: " + (end - start));
View Full Code Here

    InstanceSet testset = splitsets[1]
   
    /**
     * 建立分类器
     */   
    OnlineTrainer trainer = new OnlineTrainer(af);
    Linear pclassifier = trainer.train(trainset);
    pp.removeTargetPipe();
    pclassifier.setPipe(pp);
    af.setStopIncrement(true);
   
    //将分类器保存到模型文件
View Full Code Here

    }     
   
    /**
     * 建立分类器
     */   
    OnlineTrainer trainer3 = new OnlineTrainer(af3);
    Linear pclassifier = trainer3.train(trainset);
    pp.removeTargetPipe();
    pclassifier.setPipe(pp);
    af.setStopIncrement(true);
   
    //将分类器保存到模型文件
View Full Code Here

    } else {
      inference = new HigherOrderViterbi(templets, labels.size());
      update = new HigherOrderViterbiPAUpdate(templets, labels.size(), true);
    }

    OnlineTrainer trainer = new OnlineTrainer(inference, update, loss,
        features.size(), iterNum, c1);
   
    trainer.innerOptimized = false;
    trainer.finalOptimized = true;

    cl = trainer.train(trainSet, testSet);

//    ModelAnalysis.removeZero(cl);

    saveTo(model);
View Full Code Here

   
   
    /**
     * 建立分类器
     */   
    OnlineTrainer trainer = new OnlineTrainer(af);
    Linear pclassifier = trainer.train(trainset);
    pp.removeTargetPipe();
    pclassifier.setPipe(pp);
    af.setStopIncrement(true);
   
    //将分类器保存到模型文件
View Full Code Here

      System.out.printf("Training with data: %s\n", pos);
      System.out.printf("Number of labels: %d\n", ysize);
      LinearMax solver = new LinearMax(generator, ysize);
      ZeroOneLoss loss = new ZeroOneLoss();
      Update update = new LinearMaxPAUpdate(loss);
      OnlineTrainer trainer = new OnlineTrainer(solver, update, loss,
          fsize, maxite, c);
      models[i] = trainer.train(instset, null);
      instset = null;
      solver = null;
      loss = null;
      trainer = null;
      System.out.println();
View Full Code Here

TOP

Related Classes of org.fnlp.ml.classifier.linear.OnlineTrainer

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.