예제 #1
0
  public void initializeExamples(ClusAttrType[] attrs, RowData data) {
    // first remove all examplelists from attributes (-> ensembles!)
    for (int i = 0; i < attrs.length; i++) {
      ClusAttrType at = attrs[i];
      if (at.isSparse()) {
        ((SparseNumericAttrType) at).resetExamples();
      }
    }

    for (int i = 0; i < data.getNbRows(); i++) {
      SparseDataTuple tuple = (SparseDataTuple) data.getTuple(i);
      tuple.addExampleToAttributes();
    }
  }
예제 #2
0
  public void induce(ClusNode node, RowData data) {
    if (getSettings().isEnsembleMode()
        && ((getSettings().getEnsembleMethod() == Settings.ENSEMBLE_RFOREST)
            || (getSettings().getEnsembleMethod() == Settings.ENSEMBLE_NOBAGRFOREST))) {
      induceRandomForest(node, data);
    } else {
      ClusAttrType[] attrs = getDescriptiveAttributes();
      initializeExamples(attrs, data);
      ArrayList<ClusAttrType> attrList = new ArrayList<ClusAttrType>();
      ArrayList<ArrayList> examplelistList = new ArrayList<ArrayList>();
      for (int i = 0; i < attrs.length; i++) {
        ClusAttrType at = attrs[i];
        if (at.isSparse()) {
          if (((SparseNumericAttrType) at).getExampleWeight() >= getSettings().getMinimalWeight()) {
            attrList.add(at);

            Object[] exampleArray = ((SparseNumericAttrType) at).getExamples().toArray();
            RowData exampleData = new RowData(exampleArray, exampleArray.length);
            exampleData.sortSparse((SparseNumericAttrType) at, m_FindBestTest.getSortHelper());
            ArrayList<SparseDataTuple> exampleList = new ArrayList<SparseDataTuple>();
            for (int j = 0; j < exampleData.getNbRows(); j++) {
              exampleList.add((SparseDataTuple) exampleData.getTuple(j));
            }
            ((SparseNumericAttrType) at).setExamples(exampleList);
            examplelistList.add(exampleList);
          }
        } else {
          attrList.add(at);
          examplelistList.add(null);
        }
      }
      Object[] attrArray = attrList.toArray();
      Object[] examplelistArray = examplelistList.toArray();
      induce(node, data, attrArray, examplelistArray);
    }
  }