Package org.fnlp.ml.types

Examples of org.fnlp.ml.types.Instance


    for(int i=0;i<numLabels;i++){
      means[i]=new HashSparseVector();
    }

    for (int ii = 0; ii < trainingList.size(); ii++){
      Instance inst = trainingList.getInstance(ii);
      ISparseVector fv = (ISparseVector) inst.getData ();
      int target = (Integer) inst.getTarget();
      if(tree!=null){
        int[] anc = tree.getPath(target);
        for(int j=0;j<anc.length;j++){
          means[anc[j]].plus(fv);
          classNum[anc[j]]+=1;
View Full Code Here


      float totalerror = 0;
      trainingList.shuffle();
      long beginTimeInner = System.currentTimeMillis();
      for (int ii = 0; ii < numSamples; ii++) {

        Instance inst = trainingList.getInstance(ii);
        int maxC = (Integer) inst.getTarget();
       
//        HashSet<Integer> t = new HashSet<Integer>();
//        t.add(maxC);
        Predict pred = (Predict) msolver.getBest(inst, 1);
       
        //从临时数据中取出正确标签打分信息,并删除
        Predict oracle = (Predict) inst.getTempData();
        inst.deleteTempData();
       
        int maxE = pred.getLabel(0);
        int error;
        if (tree == null) {
          error = (pred.getLabel(0) == maxC) ? 0 : 1;
View Full Code Here

        return classdataList;
    }

    private void calCounts() {
        for (int ii = 0; ii < instanceSet.size(); ii++) {
            Instance inst = instanceSet.getInstance(ii);
            int[][] data = (int[][]) inst.getData();
            int[] golds = (int[]) inst.getTarget();
           
            for (int i = 0; i < data.length; i++) {
                for (int j = 0; j < data[0].length; j++) {
                    int idx = data[i][j] + golds[i];
                    if (idx >= 0)
View Full Code Here

   * @throws UnsupportedDataTypeException
   */
  private float[][] estimateActions(ParsingState state) throws UnsupportedDataTypeException {
    // 当前状态的特征
    HashSparseVector features = state.getFeatures();
    Instance inst = new Instance(features.indices());

    String pos = state.getLeftPos();
    int lpos = postagAlphabet.lookupIndex(pos);
    if(lpos==-1)
      throw new UnsupportedDataTypeException("不支持词性:"+pos);
View Full Code Here

TOP

Related Classes of org.fnlp.ml.types.Instance

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.