Package org.fnlp.ml.classifier.hier

Examples of org.fnlp.ml.classifier.hier.Linear


    BaseGenerator featureGen = new BaseGenerator();
    ZeroOneLoss loss = new ZeroOneLoss();
    Inferencer msolver = new MultiLinearMax(featureGen, al, null,2);

    PATrainer trainer = new PATrainer(msolver, featureGen, loss, round,c, null);
    Linear pclassifier = trainer.train(train, null);
   
    String modelFile = path+".m.gz";
    pclassifier.saveTo(modelFile);

    long end = System.currentTimeMillis();
    System.out.println("Total Time: " + (end - start));
    System.out.println("End!");
    (new File(modelFile)).deleteOnExit();
View Full Code Here


    BaseGenerator featureGen = new BaseGenerator();
    ZeroOneLoss loss = new ZeroOneLoss();
    Inferencer msolver = new MultiLinearMax(featureGen, lf, null,2);

    PATrainer trainer = new PATrainer(msolver, featureGen, loss, round,c, null);
    Linear pclassifier = trainer.train(trainset, null);
    String modelFile = "./tmp/m.gz";
    pclassifier.saveTo(modelFile);
    pclassifier = null;
   
    System.out.println("分类器测试");
    pclassifier = Linear.loadFrom(modelFile);
    float[] tdata = new float[]{1,0,1};
    ISparseVector sv = new HashSparseVector(tdata,true);
    Instance inst = new Instance(sv);
    String lab = pclassifier.getStringLabel(inst);
    System.out.println("分类结果:\t"+lab);
   

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

TOP

Related Classes of org.fnlp.ml.classifier.hier.Linear

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.