Пример #1
0
  /**
   * Generates the classifier.
   *
   * @param instances the data to train with
   * @throws Exception if classifier can't be built successfully
   */
  @Override
  public void buildClassifier(Instances instances) throws Exception {

    // can classifier handle the data?
    getCapabilities().testWithFail(instances);

    // remove instances with missing class
    instances = new Instances(instances);
    instances.deleteWithMissingClass();

    ModelSelection modSelection;

    if (m_binarySplits) {
      modSelection =
          new BinC45ModelSelection(
              m_minNumObj, instances, m_useMDLcorrection, m_doNotMakeSplitPointActualValue);
    } else {
      modSelection =
          new C45ModelSelection(
              m_minNumObj, instances, m_useMDLcorrection, m_doNotMakeSplitPointActualValue);
    }
    if (m_unpruned) {
      m_root = new MakeDecList(modSelection, m_minNumObj);
    } else if (m_reducedErrorPruning) {
      m_root = new MakeDecList(modSelection, m_numFolds, m_minNumObj, m_Seed);
    } else {
      m_root = new MakeDecList(modSelection, m_CF, m_minNumObj);
    }
    m_root.buildClassifier(instances);
    if (m_binarySplits) {
      ((BinC45ModelSelection) modSelection).cleanup();
    } else {
      ((C45ModelSelection) modSelection).cleanup();
    }
  }
Пример #2
0
  /**
   * Returns a description of the classifier
   *
   * @return a string representation of the classifier
   */
  @Override
  public String toString() {

    if (m_root == null) {
      return "No classifier built";
    }
    return "PART decision list\n------------------\n\n" + m_root.toString();
  }
Пример #3
0
 /**
  * Return the number of rules.
  *
  * @return the number of rules
  */
 public double measureNumRules() {
   return m_root.numRules();
 }
Пример #4
0
  /**
   * Returns a superconcise version of the model
   *
   * @return a concise version of the model
   */
  @Override
  public String toSummaryString() {

    return "Number of rules: " + m_root.numRules() + "\n";
  }
Пример #5
0
  /**
   * Returns class probabilities for an instance.
   *
   * @param instance the instance to get the distribution for
   * @return the class probabilities
   * @throws Exception if the distribution can't be computed successfully
   */
  @Override
  public final double[] distributionForInstance(Instance instance) throws Exception {

    return m_root.distributionForInstance(instance);
  }
Пример #6
0
  /**
   * Classifies an instance.
   *
   * @param instance the instance to classify
   * @return the classification
   * @throws Exception if instance can't be classified successfully
   */
  @Override
  public double classifyInstance(Instance instance) throws Exception {

    return m_root.classifyInstance(instance);
  }