Package org.encog.ml.data.versatile.columns

Examples of org.encog.ml.data.versatile.columns.ColumnDefinition


   *            The column type.
   * @return The column definition
   */
  public ColumnDefinition defineSourceColumn(String name, int index,
      ColumnType colType) {
    ColumnDefinition result = new ColumnDefinition(name, colType);
    result.setIndex(index);
    addSourceColumn(result);
    return result;
  }
View Full Code Here


   * @param value
   *            The value to normalize.
   * @return The normalized result.
   */
  public double[] normalizeInputColumn(int i, String value) {
    ColumnDefinition colDef = this.inputColumns.get(i);
    double[] result = new double[this.normStrategy.normalizedSize(colDef,
        true)];
    this.normStrategy.normalizeColumn(colDef, true, value, result, 0);
    return result;
  }
View Full Code Here

   * @param value
   *            The value to normalize.
   * @return The normalized result.
   */
  public double[] normalizeOutputColumn(int i, String value) {
    ColumnDefinition colDef = this.outputColumns.get(i);
    double[] result = new double[this.normStrategy.normalizedSize(colDef,
        false)];
    this.normStrategy.normalizeColumn(colDef, false, value, result, 0);
    return result;
  }
View Full Code Here

  public String[] denormalizeOutputVectorToString(MLData output) {
    String[] result = new String[this.outputColumns.size()];

    int idx = 0;
    for (int i = 0; i < this.outputColumns.size(); i++) {
      ColumnDefinition colDef = this.outputColumns.get(i);
      result[i] = this.normStrategy.denormalizeColumn(colDef, false,
          output, idx);
      idx += this.normStrategy.normalizedSize(colDef, false);
    }
View Full Code Here

    this.source.rewind();
    int c = 0;
    while ((line = this.source.readLine()) != null) {
      c++;
      for (int i = 0; i < this.helper.getSourceColumns().size(); i++) {
        ColumnDefinition colDef = this.helper.getSourceColumns().get(i);
        int index = findIndex(colDef);
        String value = line[index];
        colDef.analyze(value);
      }
    }
    this.analyzedRows = c;

    // Calculate the means, and reset for sd calc.
    for (ColumnDefinition colDef : this.helper.getSourceColumns()) {
      // Only calculate mean/sd for continuous columns.
      if (colDef.getDataType() == ColumnType.continuous) {
        colDef.setMean(colDef.getMean() / colDef.getCount());
        colDef.setSd(0);
      }
    }

    // Sum the standard deviation
    this.source.rewind();
    while ((line = this.source.readLine()) != null) {
      for (int i = 0; i < this.helper.getSourceColumns().size(); i++) {
        ColumnDefinition colDef = this.helper.getSourceColumns().get(i);
        String value = line[i];
        if (colDef.getDataType() == ColumnType.continuous) {
          double d = this.helper.parseDouble(value);
          d = colDef.getMean() - d;
          d = d * d;
          colDef.setSd(colDef.getSd() + d);
        }
      }
    }

    // Calculate the standard deviations.
    for (ColumnDefinition colDef : this.helper.getSourceColumns()) {
      // Only calculate sd for continuous columns.
      if (colDef.getDataType() == ColumnType.continuous) {
        colDef.setSd(Math.sqrt(colDef.getSd() / colDef.getCount()));
      }
    }
  }
View Full Code Here

   * @param data The data to use.
   * @return The error.
   */
  public double calculateError(MLMethod method, MLDataSet data) {
    if (this.dataset.getNormHelper().getOutputColumns().size() == 1) {
      ColumnDefinition cd = this.dataset.getNormHelper()
          .getOutputColumns().get(0);
      if (cd.getDataType() == ColumnType.nominal) {
        return EncogUtility.calculateClassificationError(
            (MLClassification) method, data);
      }
    }

View Full Code Here

TOP

Related Classes of org.encog.ml.data.versatile.columns.ColumnDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.