Package org.fnlp.ml.types

Examples of org.fnlp.ml.types.Instance


    this.index = 0;
  }

  public Instance next ()
  {
    return new Instance (data[index++], null);
  }
View Full Code Here


    this.index = 0;
  }

  public Instance next ()
  {
    return new Instance (data[index++], null);
  }
View Full Code Here

      return null;
    }
    if(isSplited){
      String[] tokens = data.split("\\t+|\\s+");
      List<String> newdata = Arrays.asList(tokens);
      return new Instance (newdata,label);
    }else
      return new Instance (data, label);
  }
View Full Code Here

   * @param instSet
   * @throws Exception
   */
  public void process(InstanceSet instSet) throws Exception {
    for(int i=0; i < instSet.size(); i++){
      Instance inst = instSet.getInstance(i);
      addThruPipe(inst);
    }
  }
View Full Code Here

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    cur = new Instance(buff.toString(), f.getPath());
    buff = null;
  }
View Full Code Here

    }
  }

  public Instance next() {
    int idx = currentFile.getName().indexOf(".");
    return new Instance (content,currentFile.getName().substring(0, idx));
  }
View Full Code Here

   
   
    Iterator i = insts.iterator();

    while (i.hasNext()) {
      Instance d = (Instance) i.next();

      centroid.plus((HashSparseVector) d.getData());
    }
    centroid.scaleDivide(insts.size());

    return centroid;
  }
View Full Code Here

      HashSparseVector centroid) {
    float quality = 0.0f;
    HashSparseVector c = centroid;

    for (int i = 0; i < docs.size(); ++i) {
      Instance doc = docs.get(i);

      quality += c.distanceEuclidean((HashSparseVector) doc.getData());
    }

    return quality;
  }
View Full Code Here

        /*
         *  Store the document the loops have selected in the 'doc' variable.
         * Store is vector in the 'docVec' variable for easy access.
         */
        Instance doc = this.assignedClusters[clusterNum].get(docNum);
        HashSparseVector docVec = (HashSparseVector) doc.getData();

        int bestClusterNum = clusterNum;    // Assume we are already in the best cluster.
        double distanceToCurrentCentroid =
          this.centroids[clusterNum].distanceEuclidean(docVec);
        double squareDistanceOfBestCluster = distanceToCurrentCentroid;
View Full Code Here

        float value = Float.parseFloat(taken[1]);
        int idx = Integer.parseInt(taken[0]);
        sv.put(idx, value);
      }
    }
    return new Instance(sv, tokens[0]);
  }
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.