Examples of Linear


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

  }

  public void optimizeTag(String file) throws IOException,
  ClassNotFoundException {
    ModelIO.loadFrom(file);
    Linear cl=ModelIO.cl;
    TempletGroup templates=ModelIO.templets;   
    ModelIO.saveTo(file+".bak", templates, cl);
    removeZero(cl);
    ModelIO.saveTo(file,templates,cl);
    System.out.print("Done");
View Full Code Here

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

    ModelIO.saveTo(file,templates,cl);
    System.out.print("Done");
  }

  public void optimizeDep(String file) throws LoadModelException, IOException {
    Linear cl= Linear.loadFrom(file)
    cl.saveTo(file+".bak");
    removeZero(cl);
    cl.saveTo(file);
    System.out.print("Done");
  }
View Full Code Here

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


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

    Linear cl = trainer.train(trainSet);


    // test data没有标注
    Pipe tpipe = featurePipe;
    // 测试集
    InstanceSet testSet = new InstanceSet(tpipe);

    testSet.loadThruPipes(new SequenceReader(testfile, false, "utf8"));
    System.out.println("测试样本个数: " + testSet.size()); //
    String[][] labelsSet = new String[testSet.size()][];
    for (int i = 0; i < testSet.size(); i++) {
      Instance carrier = testSet.get(i);
      int[] pred = (int[]) cl.classify(carrier).getLabel(0);
      labelsSet[i] = labels.lookupString(pred);
    }
   
    String s = SimpleFormatter.format(testSet, labelsSet);
    System.out.println(s);
View Full Code Here

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

   
    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));
    System.out.println("End!");
    (new File(modelFile)).deleteOnExit();
View Full Code Here

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

   
    /**
     * 建立分类器
     */   
    OnlineTrainer trainer = new OnlineTrainer(af);
    Linear pclassifier = trainer.train(trainset);
    pp.removeTargetPipe();
    pclassifier.setPipe(pp);
    af.setStopIncrement(true);
   
    //将分类器保存到模型文件
    pclassifier.saveTo(modelFile)
    pclassifier = null;
   
    //从模型文件读入分类器
    Linear cl =Linear.loadFrom(modelFile);
   
    //性能评测
    Evaluation eval = new Evaluation(testset);
    eval.eval(cl,1);

    /**
     * 测试
     */
    System.out.println("类别 : 文本内容");
    System.out.println("===================");
    for(int i=0;i<testset.size();i++){
      Instance data = testset.getInstance(i);
     
      Integer gold = (Integer) data.getTarget();
      String pred_label = cl.getStringLabel(data);
      String gold_label = cl.getLabel(gold);
     
      if(pred_label.equals(gold_label))
        System.out.println(pred_label+" : "+testset.getInstance(i).getSource());
      else
        System.err.println(gold_label+"->"+pred_label+" : "+testset.getInstance(i).getSource());
    }
   
   
    /**
     * 分类器使用
     */
    String str = "韦德:不拿冠军就是失败 詹皇:没拿也不意味失败";
    System.out.println("============\n分类:"+ str);
    Pipe p = cl.getPipe();
    Instance inst = new Instance(str);
    try {
      //特征转换
      p.addThruPipe(inst);
    } catch (Exception e) {
      e.printStackTrace();
    }
    String res = cl.getStringLabel(inst);
    System.out.println("类别:"+ res);
    //清除模型文件
    (new File(modelFile)).deleteOnExit();
    System.exit(0);
  }
View Full Code Here

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

   
    /**
     * 建立分类器
     */   
    OnlineTrainer trainer3 = new OnlineTrainer(af3);
    Linear pclassifier = trainer3.train(trainset);
    pp.removeTargetPipe();
    pclassifier.setPipe(pp);
    af.setStopIncrement(true);
   
    //将分类器保存到模型文件
    pclassifier.saveTo(linearModelFile)
    pclassifier = null;
   
    //从模型文件读入分类器
    Linear cl =Linear.loadFrom(linearModelFile);
   
    //性能评测
    Evaluation eval = new Evaluation(testset);
    eval.eval(cl,1);
    /**
     * 测试
     */
    System.out.println("类别 : 文本内容");
    System.out.println("===================");
    count=0;
    for(int i=0;i<testset.size();i++){
      Instance data = testset.getInstance(i);
     
      Integer gold = (Integer) data.getTarget();
      String pred_label = cl.getStringLabel(data);
      String gold_label = cl.getLabel(gold);
     
      if(pred_label.equals(gold_label)){
        //System.out.println(pred_label+" : "+testsetliner.getInstance(i).getSource());
        count++;
      }
View Full Code Here

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

   
    /**
     * 建立分类器
     */   
    OnlineTrainer trainer = new OnlineTrainer(af);
    Linear pclassifier = trainer.train(trainset);
    pp.removeTargetPipe();
    pclassifier.setPipe(pp);
    af.setStopIncrement(true);
   
    //将分类器保存到模型文件
    pclassifier.saveTo(modelFile)
    pclassifier = null;
   
    //从模型文件读入分类器
    Linear cl =Linear.loadFrom(modelFile);
   
    //性能评测
    Evaluation eval = new Evaluation(testset);
    eval.eval(cl,1);

View Full Code Here

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

    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);
    Linear models = trainer.train(instset, null);
    instset = null;
    solver = null;
    loss = null;
    trainer = null;
    System.out.println();
    factory.setStopIncrement(true);
    models.saveTo(modelfile);

  }
View Full Code Here

Examples of org.jquantlib.math.interpolations.factories.Linear

                        if (ts.interpolator().global()) {
                            throw new LibraryException("no chance to fix it in a later iteration");
                        }

                        // otherwise, if the target interpolation is not usable yet
                        ts.setInterpolation(new Linear().interpolate (new Array(times, i+1), new Array(data)));
                    }
                }
                // required because we just changed the data
                // is it really required?
                ts.interpolation().update();
View Full Code Here

Examples of org.jquantlib.math.interpolations.factories.Linear

        final RateHelper[] instruments = null;
        final DayCounter dc = new DayCounter();
        final Handle<Quote> jumps[] = null;
        final Date[] jumpDates = null;
        final double accuracy = 0;
        final org.jquantlib.math.interpolations.Interpolation.Interpolator i = new Linear();
        final org.jquantlib.termstructures.Bootstrap b = new IterativeBootstrap(PiecewiseYieldCurve.class);


        final PiecewiseYieldCurve<Discount, Linear, IterativeBootstrap> pyc = new PiecewiseYieldCurve<Discount, Linear, IterativeBootstrap>(
                d, instruments, dc, jumps, jumpDates, accuracy, i, b) { /* anonymous */ };
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.