Package org.encog.app.analyst.script

Examples of org.encog.app.analyst.script.DataField


  public int determineMode(EncogAnalyst analyst) {
    if( !this.isClassify() ) {
      throw new AnalystError("Can only calculate the mode for a class.");
    }
   
    DataField df = analyst.getScript().findDataField(this.name);
    AnalystClassItem m = null;
    int result = 0;
    int idx = 0;
    for( AnalystClassItem item: df.getClassMembers() )
    {
      if( m==null || m.getCount()<item.getCount() ) {
        m = item;
        result = idx;
      }
View Full Code Here


    if (this.normalizedFields == null) {
      return;
    }

    for (final AnalystField norm : this.normalizedFields) {
      final DataField f = script.findDataField(norm.getName());

      if (f == null) {
        throw new AnalystError("Normalize specifies unknown field: "
            + norm.getName());
      }

      if (norm.getAction() == NormalizationAction.Normalize) {
        norm.setActualHigh(f.getMax());
        norm.setActualLow(f.getMin());
      }

      if ((norm.getAction() == NormalizationAction.Equilateral)
          || (norm.getAction() == NormalizationAction.OneOf)
          || (norm.getAction() == NormalizationAction.SingleField)) {

        int index = 0;
        for (final AnalystClassItem item : f.getClassMembers()) {
          norm.getClasses().add(
              new ClassItem(item.getName(), index++));
        }
      }
    }
View Full Code Here

    if( stat.isClassify() ) {
      int m = stat.determineMode(analyst);
      return stat.encode(m);
    } else {
    // mean
      DataField df = analyst.getScript().findDataField(stat.getName());
      double[] result = new double[1];
      result[0] = df.getMean();
      return result;
    }
  }
View Full Code Here

      }
    }
   
    // build index to mappings
    for(int index =0; index<fields.length;index++) {
      DataField field = fields[index];
      if( isAxis(field.getName(),axis)) {
        this.axisMapping.put(field.getName().toLowerCase(), index);
      }     
    }
  }
View Full Code Here

      boolean success = false;

      if (this.goal == AnalystGoal.Classification) {
        // first try to the last classify field
        for (final AnalystField field : fields) {
          final DataField df = this.script.findDataField(field
              .getName());
          if (field.getAction().isClassify() && df.isClass()) {
            this.targetField = field.getName();
            success = true;
          }
        }
      } else {

        // otherwise, just return the last regression field
        for (final AnalystField field : fields) {
          final DataField df = this.script.findDataField(field
              .getName());
          if (!df.isClass() && (df.isReal() || df.isInteger())) {
            this.targetField = field.getName();
            success = true;
          }
        }
      }

      if (!success) {
        throw new AnalystError(
            "Can't determine target field automatically, "
          + "please specify one.\nThis can also happen if you "
            + "specified the wrong file format.");
      }
    } else {
      if (this.script.findDataField(this.targetField) == null) {
        throw new AnalystError("Invalid target field: "
            + this.targetField);
      }
    }

    this.script.getProperties().setProperty(
        ScriptProperties.DATA_CONFIG_GOAL, this.goal);

    if (!this.timeSeries && this.taskBalance) {
      this.script.getProperties().setProperty(
          ScriptProperties.BALANCE_CONFIG_BALANCE_FIELD,
          this.targetField);
      final DataField field = this.analyst.getScript().findDataField(
          this.targetField);
      if ((field != null) && field.isClass()) {
        final int countPer = field.getMinClassCount();
        this.script.getProperties().setProperty(
            ScriptProperties.BALANCE_CONFIG_COUNT_PER, countPer);
      }
    }

    // now that the target field has been determined, set the analyst fields
    AnalystField af = null;
    for (final AnalystField field : this.analyst.getScript().getNormalize()
        .getNormalizedFields()) {
      if ((field.getAction() != NormalizationAction.Ignore)
          && field.getName().equalsIgnoreCase(this.targetField)) {
        if ((af == null) || (af.getTimeSlice() < field.getTimeSlice())) {
          af = field;
        }
      }
    }

    if (af != null) {
      af.setOutput(true);
    }

    // set the clusters count
    if (this.taskCluster) {
      if ((this.targetField.length() == 0)
          || (this.goal != AnalystGoal.Classification)) {
        this.script.getProperties().setProperty(
            ScriptProperties.CLUSTER_CONFIG_CLUSTERS, 2);
      } else {
        final DataField tf = this.script
            .findDataField(this.targetField);
        this.script.getProperties().setProperty(
            ScriptProperties.CLUSTER_CONFIG_CLUSTERS,
            tf.getClassMembers().size());
      }
    }
  }
View Full Code Here

        .getNormalizedFields();
    norm.clear();
    final DataField[] dataFields = this.script.getFields();

    for (int i = 0; i < this.script.getFields().length; i++) {
      final DataField f = dataFields[i];

      NormalizationAction action;
      final boolean isLast = i == this.script.getFields().length - 1;

      if ((f.isInteger() || f.isReal()) && !f.isClass()) {
        action = NormalizationAction.Normalize;
        AnalystField af;
        if (this.range == NormalizeRange.NegOne2One) {
          af = new AnalystField(f.getName(), action, 1, -1);
        } else {         
          af = new AnalystField(f.getName(), action, 1, 0);
        }
        norm.add(af);
        af.setActualHigh(f.getMax());
        af.setActualLow(f.getMin());
      } else if (f.isClass()) {
        if (isLast && this.directClassification) {
          action = NormalizationAction.SingleField;
        } else if (f.getClassMembers().size() > 2) {
          action = NormalizationAction.Equilateral;
        } else {
          action = NormalizationAction.OneOf;
        }

        if (this.range == NormalizeRange.NegOne2One) {
          norm.add(new AnalystField(f.getName(), action, 1, -1));
        } else {
          norm.add(new AnalystField(f.getName(), action, 1, 0));
        }
      } else {
        action = NormalizationAction.Ignore;
        norm.add(new AnalystField(action, f.getName()));
      }
    }

    this.script.getNormalize().init(this.script);
  }
View Full Code Here

    // get other config data
    final int countPer = getProp().getPropertyInt(
        ScriptProperties.BALANCE_CONFIG_COUNT_PER);
    final String targetFieldStr = getProp().getPropertyString(
        ScriptProperties.BALANCE_CONFIG_BALANCE_FIELD);
    final DataField targetFieldDF = getAnalyst().getScript().findDataField(
        targetFieldStr);
    if (targetFieldDF == null) {
      throw new AnalystError("Can't find balance target field: "
          + targetFieldStr);
    }
    if (!targetFieldDF.isClass()) {
      throw new AnalystError("Can't balance on non-class field: "
          + targetFieldStr);
    }

    final int targetFieldIndex = getAnalyst().getScript()
View Full Code Here

  /**
   * Finalize the field, and create a DataField.
   * @return The new DataField.
   */
  public final DataField finalizeField() {
    final DataField result = new DataField(getName());

    result.setName(getName());
    result.setMin(getMin());
    result.setMax(getMax());
    result.setMean(getMean());
    result.setStandardDeviation(getStandardDeviation());
    result.setInteger(isInteger());
    result.setReal(isReal());
    result.setClass(isClass());
    result.setComplete(isComplete());

    result.getClassMembers().clear();

    if (result.isClass()) {
      final List<AnalystClassItem> list = getAnalyzedClassMembers();
      result.getClassMembers().addAll(list);
    }

    return result;
  }
View Full Code Here

    int idx = 0;
    for (final AnalystField field : getAnalyst().getScript().getNormalize()
        .getNormalizedFields()) {
      if (field.isInput()) {

        final DataField df = getAnalyst().getScript().findDataField(
            field.getName());
        String str;

        switch (field.getAction()) {
        case PassThrough:
          str = EngineArray.replace(df.getSource(), "##", "pos+"
              + (-field.getTimeSlice()));
          addLine("input[" + idx + "]=" + str + ";");
          idx++;
          break;
        case Normalize:
          str = EngineArray.replace(df.getSource(), "##", "pos+"
              + (-field.getTimeSlice()));
          addLine("input[" + idx + "]=Norm(" + str + ","
              + field.getNormalizedHigh() + ","
              + field.getNormalizedLow() + ","
              + field.getActualHigh() + ","
View Full Code Here

    addLine("FileWrite(iHandle, when,");

    final DataField[] fields = getAnalyst().getScript().getFields();
    String lastLine = null;
    for (final DataField field : fields) {
      final DataField df = field;
      if (!df.getName().equalsIgnoreCase("time")
          && !df.getName().equalsIgnoreCase("prediction")) {
        final String str = EngineArray.replace(df.getSource(), "##",
            "pos");
        if (lastLine != null) {
          addLine(lastLine + ",");
        }
        lastLine = str;
View Full Code Here

TOP

Related Classes of org.encog.app.analyst.script.DataField

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.