/**
   * Save the normalization data.
   *
   * @param out The output file.
   */
  private void saveNormalize(final EncogWriteHelper out) {
    saveSubSection(out, "NORMALIZE", "CONFIG");

    out.addSubSection("RANGE");
    out.addColumn("name");
    out.addColumn("io");
    out.addColumn("timeSlice");
    out.addColumn("action");
    out.addColumn("high");
    out.addColumn("low");
    out.writeLine();
    for (final AnalystField field : this.script.getNormalize().getNormalizedFields()) {
      out.addColumn(field.getName());
      if (field.isInput()) {
        out.addColumn("input");
      } else {
        out.addColumn("output");
      }
      out.addColumn(field.getTimeSlice());
      switch (field.getAction()) {
        case Ignore:
          out.addColumn("ignore");
          break;
        case Normalize:
          out.addColumn("range");
          break;
        case PassThrough:
          out.addColumn("pass");
          break;
        case OneOf:
          out.addColumn("oneof");
          break;
        case Equilateral:
          out.addColumn("equilateral");
          break;
        case SingleField:
          out.addColumn("single");
          break;
        default:
          throw new AnalystError("Unknown action: " + field.getAction());
      }

      out.addColumn(field.getNormalizedHigh());
      out.addColumn(field.getNormalizedLow());
      out.writeLine();
    }
  }
  /**
   * Produce the report.
   *
   * @return The report.
   */
  public String produceReport() {
    final HTMLReport report = new HTMLReport();

    analyzeFile();
    report.beginHTML();
    report.title("Encog Analyst Report");
    report.beginBody();

    report.h1("General Statistics");
    report.beginTable();
    report.tablePair("Total row count", Format.formatInteger(this.rowCount));
    report.tablePair("Missing row count", Format.formatInteger(this.missingCount));
    report.endTable();

    report.h1("Field Ranges");
    report.beginTable();
    report.beginRow();
    report.header("Name");
    report.header("Class?");
    report.header("Complete?");
    report.header("Int?");
    report.header("Real?");
    report.header("Max");
    report.header("Min");
    report.header("Mean");
    report.header("Standard Deviation");
    report.endRow();

    for (final DataField df : this.analyst.getScript().getFields()) {
      report.beginRow();
      report.cell(df.getName());
      report.cell(Format.formatYesNo(df.isClass()));
      report.cell(Format.formatYesNo(df.isComplete()));
      report.cell(Format.formatYesNo(df.isInteger()));
      report.cell(Format.formatYesNo(df.isReal()));
      report.cell(Format.formatDouble(df.getMax(), FIVE_SPAN));
      report.cell(Format.formatDouble(df.getMin(), FIVE_SPAN));
      report.cell(Format.formatDouble(df.getMean(), FIVE_SPAN));
      report.cell(Format.formatDouble(df.getStandardDeviation(), FIVE_SPAN));
      report.endRow();

      if (df.getClassMembers().size() > 0) {
        report.beginRow();
        report.cell(" ");
        report.beginTableInCell(EIGHT_SPAN);
        report.beginRow();
        report.header("Code");
        report.header("Name");
        report.header("Count");
        report.endRow();
        for (final AnalystClassItem item : df.getClassMembers()) {
          report.beginRow();
          report.cell(item.getCode());
          report.cell(item.getName());
          report.cell(Format.formatInteger(item.getCount()));
          report.endRow();
        }
        report.endTableInCell();
        report.endRow();
      }
    }

    report.endTable();

    report.h1("Normalization");
    report.beginTable();
    report.beginRow();
    report.header("Name");
    report.header("Action");
    report.header("High");
    report.header("Low");
    report.endRow();

    for (final AnalystField item : this.analyst.getScript().getNormalize().getNormalizedFields()) {
      report.beginRow();
      report.cell(item.getName());
      report.cell(item.getAction().toString());
      report.cell(Format.formatDouble(item.getNormalizedHigh(), FIVE_SPAN));
      report.cell(Format.formatDouble(item.getNormalizedLow(), FIVE_SPAN));
      report.endRow();
    }

    report.endTable();

    report.h1("Machine Learning");
    report.beginTable();
    report.beginRow();
    report.header("Name");
    report.header("Value");
    report.endRow();

    final String t =
        this.analyst.getScript().getProperties().getPropertyString(ScriptProperties.ML_CONFIG_TYPE);
    final String a =
        this.analyst
            .getScript()
            .getProperties()
            .getPropertyString(ScriptProperties.ML_CONFIG_ARCHITECTURE);
    final String rf =
        this.analyst
            .getScript()
            .getProperties()
            .getPropertyString(ScriptProperties.ML_CONFIG_MACHINE_LEARNING_FILE);

    report.tablePair("Type", t);
    report.tablePair("Architecture", a);
    report.tablePair("Machine Learning File", rf);
    report.endTable();

    report.h1("Files");
    report.beginTable();
    report.beginRow();
    report.header("Name");
    report.header("Filename");
    report.endRow();
    for (final String key : this.analyst.getScript().getProperties().getFilenames()) {
      final String value = this.analyst.getScript().getProperties().getFilename(key);
      report.beginRow();
      report.cell(key);
      report.cell(value);
      report.endRow();
    }
    report.endTable();

    report.endBody();
    report.endHTML();

    return report.toString();
  }