コード例 #1
0
 @Override
 protected boolean parseInner(XmlPullParser parser, Instance instance) throws Exception {
   if (super.parseInner(parser, instance)) return true;
   if (getValueName().equals(parser.getName())) {
     instance.setValue(ProviderUtils.parseText(parser));
     return true;
   }
   return false;
 }
コード例 #2
0
ファイル: Discretizer.java プロジェクト: Jungwon/mltk
 /**
  * Discretizes an attribute using bins.
  *
  * @param instances the dataset to discretize.
  * @param attIndex the attribute index.
  * @param bins the bins.
  */
 public static void discretize(Instances instances, int attIndex, Bins bins) {
   Attribute attribute = instances.getAttributes().get(attIndex);
   BinnedAttribute binnedAttribute = new BinnedAttribute(attribute.getName(), bins);
   binnedAttribute.setIndex(attribute.getIndex());
   instances.getAttributes().set(attIndex, binnedAttribute);
   for (Instance instance : instances) {
     int v = bins.getIndex(instance.getValue(attribute.getIndex()));
     instance.setValue(attribute.getIndex(), v);
   }
 }
コード例 #3
0
  public void buildClusterer(ArrayList<String> seqDB, double[][] sm) {
    seqList = seqDB;

    this.setSimMatrix(sm);

    Attribute seqString = new Attribute("sequence", (FastVector) null);
    FastVector attrInfo = new FastVector();
    attrInfo.addElement(seqString);
    Instances data = new Instances("data", attrInfo, 0);

    for (int i = 0; i < seqList.size(); i++) {
      Instance currentInst = new Instance(1);
      currentInst.setDataset(data);
      currentInst.setValue(0, seqList.get(i));
      data.add(currentInst);
    }

    try {
      buildClusterer(data);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }