Ejemplo n.º 1
0
  /**
   * Generates the classifier.
   *
   * @param instances the data to train the classifier with
   * @throws Exception if classifier can't be built successfully
   */
  public void buildClassifier(Instances instances) throws Exception {

    ModelSelection modSelection;

    if (m_binarySplits)
      modSelection = new BinC45ModelSelection(m_minNumObj, instances, m_useMDLcorrection);
    else modSelection = new C45ModelSelection(m_minNumObj, instances, m_useMDLcorrection);
    if (!m_reducedErrorPruning)
      m_root =
          new C45PruneableClassifierTree(
              modSelection, !m_unpruned, m_CF, m_subtreeRaising, !m_noCleanup, m_collapseTree);
    else
      m_root =
          new PruneableClassifierTree(modSelection, !m_unpruned, m_numFolds, !m_noCleanup, m_Seed);
    m_root.buildClassifier(instances);
    if (m_binarySplits) {
      ((BinC45ModelSelection) modSelection).cleanup();
    } else {
      ((C45ModelSelection) modSelection).cleanup();
    }
  }