Ejemplo n.º 1
0
  /**
   * Prints label for subset index of instances (eg class).
   *
   * @exception Exception if something goes wrong
   */
  public final String dumpLabel(int index, Instances data) throws Exception {

    StringBuffer text;

    text = new StringBuffer();
    text.append(((Instances) data).classAttribute().value(m_distribution.maxClass(index)));
    text.append(" (" + Utils.roundDouble(m_distribution.perBag(index), 2));
    if (Utils.gr(m_distribution.numIncorrect(index), 0))
      text.append("/" + Utils.roundDouble(m_distribution.numIncorrect(index), 2));
    text.append(")");

    return text.toString();
  }
Ejemplo n.º 2
0
  /**
   * Returns description of the boosted classifier.
   *
   * @return description of the boosted classifier as a string
   */
  public String toString() {

    // only ZeroR model?
    if (m_ZeroR != null) {
      StringBuffer buf = new StringBuffer();
      buf.append(this.getClass().getName().replaceAll(".*\\.", "") + "\n");
      buf.append(this.getClass().getName().replaceAll(".*\\.", "").replaceAll(".", "=") + "\n\n");
      buf.append("Warning: No model could be built, hence ZeroR model is used:\n\n");
      buf.append(m_ZeroR.toString());
      return buf.toString();
    }

    StringBuffer text = new StringBuffer();

    if (m_NumIterations == 0) {
      text.append("MultiBoostAB: No model built yet.\n");
    } else if (m_NumIterations == 1) {
      text.append("MultiBoostAB: No boosting possible, one classifier used!\n");
      text.append(m_Classifiers[0].toString() + "\n");
    } else {
      text.append("MultiBoostAB: Base classifiers and their weights: \n\n");
      for (int i = 0; i < m_NumIterations; i++) {
        if ((m_Classifiers != null) && (m_Classifiers[i] != null)) {
          text.append(m_Classifiers[i].toString() + "\n\n");
          text.append("Weight: " + Utils.roundDouble(m_Betas[i], 2) + "\n\n");
        } else {
          text.append("not yet initialized!\n\n");
        }
      }
      text.append("Number of performed Iterations: " + m_NumIterations + "\n");
    }

    return text.toString();
  }