Example #1
0
  private String toStringTrueFalse() {
    StringBuilder sb = new StringBuilder();

    final int COLUMN_WIDTH = 14;
    String formatString = "%" + COLUMN_WIDTH + "s";

    // make header.
    sb.append("True-False: \n-----------\n");
    sb.append(String.format(formatString, "Index"));
    sb.append(String.format(formatString, "Trials"));

    for (AlgorithmType t : AlgorithmType.values()) {
      sb.append(String.format(formatString, t));
    }
    sb.append(String.format(formatString, "Agent"));
    sb.append(String.format(formatString, "Description"));
    sb.append("\n");
    for (int i = 0; i < AlgorithmType.values().length + 4; i++)
      sb.append(String.format(formatString, "-------------"));
    sb.append("\n");

    int totalCount = 0; // for displaying the total count at the bottom.
    double weightedAgentAccuracy =
        0; // for calculating weighted accuracy rate across all question profiles.

    // display values.
    for (int i = 0; i < NUM_FEATURE_COMBOS; i++) {
      // 2016/01/05 - version 2.0.0 - added condition for
      // trial counts > 0 in order to remove the "zero" rows,
      // i.e., rows showing profile indices where there are no
      // trials.
      // Also, added the hasFeature(truefalse) condition.
      if (trialCounts[i] > 0 && Profile.hasFeature(i, FeatureType.TRUE_FALSE.ordinal())) {
        sb.append(String.format(formatString, i));
        sb.append(String.format(formatString, trialCounts[i]));

        for (int j = 0; j < AlgorithmType.values().length; j++) {
          sb.append(String.format("%" + COLUMN_WIDTH + ".3f", successProbs[i][j]));
        }
        double agentAccuracy = maxSuccessProb(successProbs[i]);
        sb.append(String.format("%" + COLUMN_WIDTH + ".3f", agentAccuracy));
        sb.append(Profile.getDescription(i));
        sb.append("\n");
        totalCount += trialCounts[i];
        weightedAgentAccuracy += trialCounts[i] * agentAccuracy;
      }
    }
    weightedAgentAccuracy /= totalCount;

    // display total trial count
    //		sb.append(String.format("%" + COLUMN_WIDTH + "s%" + COLUMN_WIDTH
    //				+ "d\n", "Total Count:", totalCount));
    sb.append(
        String.format(
            "%"
                + COLUMN_WIDTH
                + "s%"
                + COLUMN_WIDTH
                + "d%"
                + COLUMN_WIDTH * 9
                + "s%"
                + COLUMN_WIDTH
                + ".3f\n",
            "Total Count:",
            totalCount,
            " ",
            weightedAgentAccuracy));

    return new String(sb);
  }