@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;
 }
Example #2
0
 /**
  * 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);
   }
 }
  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();
    }
  }