Examples of DataField


Examples of org.apache.camel.dataformat.bindy.annotation.DataField

        int counterMandatoryFields = 0;

        for (String data : tokens) {

            // Get DataField from model
            DataField dataField = dataFields.get(pos);
            ObjectHelper.notNull(dataField, "No position " + pos + " defined for the field : " + data + ", line : " + line);

            if (dataField.required()) {
                // Increment counter of mandatory fields
                ++counterMandatoryFields;

                // Check if content of the field is empty
                // This is not possible for mandatory fields
                if (data.equals("")) {
                    throw new IllegalArgumentException("The mandatory field defined at the position " + pos + " is empty for the line : " + line);
                }
            }

            // Get Field to be setted
            Field field = annotedFields.get(pos);
            field.setAccessible(true);

            if (LOG.isDebugEnabled()) {
                LOG.debug("Pos : " + pos + ", Data : " + data + ", Field type : " + field.getType());
            }

            Format<?> format;

            // Get pattern defined for the field
            String pattern = dataField.pattern();

            // Create format object to format the field
            format = FormatFactory.getFormat(field.getType(), pattern, dataField.precision());

            // field object to be set
            Object modelField = model.get(field.getDeclaringClass().getName());

            // format the data received
View Full Code Here

Examples of org.dmg.pmml.DataField

    // Do PreProcessing on Parameters
    if(this.preProcessor != null && !this.preProcessor.isEmpty())
      processor.doScriptProcessing(this.preProcessor, parameters);
   
    for(FieldName activeField : activeFields){
      DataField dataField = this.evaluator.getDataField(activeField);
      Object value = parameters.get(dataField.getName().getValue());
     
      if(value == null || value.toString().isEmpty()) {
          result.addError("No parameter found for: " + dataField.getName());
          log.log(Level.WARNING, "No parameter found for: " + dataField.getName());
      } else {
          try {
        arguments.put(activeField, evaluator.prepare(activeField, value));
          } catch (Exception e) {
        result.addError("Field " + activeField.getValue() + " has invalid value " + value);
        log.log(Level.SEVERE, e.getMessage());
        result.setValid(false);
        return result;
          }
      }
 
    }
   
    try {
        pmmlResult = evaluator.evaluate(arguments);
    } catch (Exception e) {
        result.addError("Unable to evaluate model: " + e.getMessage());
        log.log(Level.WARNING, "Unable to evaluate model: " + e.getMessage());
        return result;
    }
   
    List<FieldName> predictedFields = evaluator.getPredictedFields();
    for(FieldName predictedField : predictedFields){
      DataField dataField = evaluator.getDataField(predictedField);
      Object predictedValue = pmmlResult.get(predictedField);
      result.addPredictedValue(dataField.getName().getValue(), predictedValue);
    }
 
    List<FieldName> resultFields = this.evaluator.getOutputFields();
    for(FieldName resultField : resultFields){
      OutputField outputField = evaluator.getOutputField(resultField);
View Full Code Here

Examples of org.dmg.pmml31.DataFieldDocument.DataField

        BigInteger pom = new BigInteger(String.valueOf(columnCount));
        dataDictionary.setNumberOfFields(pom);
       
        for (int i = 0; i < columnCount; i++)
        {
            DataField dataField = dataDictionary.addNewDataField();
            dataField.setName(colInfo[i].getName());
            dataField.setDisplayName(colInfo[i].getDisplayName());          
            //dataField[i].setDataType(DATATYPE.fromString(colInfo[i].getDataType()));
            dataField.setDataType(
                    DATATYPE.Enum.forString(colInfo[i].getDataType()));
            // all attribute are continuous in this phase
            dataField.setOptype(OPTYPE.CONTINUOUS);        
        }
       
        //ModelStat
        MiningModel miningModel = pmmlObject.addNewMiningModel();
        miningModel.setModelName("Statistica");
View Full Code Here

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

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

    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

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

    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

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

      }
    }
   
    // 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

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

      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

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

        .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

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

    // 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
TOP
Copyright © 2018 www.massapi.com. 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.