Package org.encog.ml.data

Examples of org.encog.ml.data.MLData


   
    private Object getNeuralNetworkTrainingData(NeuralData [] ndArray){
        MLDataSet trainingSet=new BasicMLDataSet();
       
        for(int i=0;i<ndArray.length;i++){
            MLData mdInput=new BasicMLData(ndArray[i].getInputVector());
            MLData mdOuput=new BasicMLData(ndArray[i].getOutputVector());
   
            trainingSet.add(mdInput, mdOuput);
        }
        return trainingSet;
    }
View Full Code Here


    }
   
    private Object getNeuralNetworkTrainingData(NeuralData [] ndArray,MLDataSet trainingSet){

        for(int i=0;i<ndArray.length;i++){
            MLData mdInput=new BasicMLData(ndArray[i].getInputVector());
            MLData mdOuput=new BasicMLData(ndArray[i].getOutputVector());
   
            trainingSet.add(mdInput, mdOuput);
        }
        return trainingSet;
    }
View Full Code Here

        EncogDirectoryPersistence.saveObject(new File(saveFilePath), neuralNetwork);
    }
   
    public NeuralData calculateAndGetOuput(NeuralData nd){
       
        MLData mdInput=new BasicMLData(nd.getInputVector());
        MLData mdOutput=neuralNetwork.compute(mdInput);
       
       
        nd.setOutputVector(mdOutput.getData());
        return nd;
    }
View Full Code Here

   
    // generate the input data

    indentLine("public static readonly double[][] INPUT_DATA = {");
    for (final MLDataPair pair : data) {
      final MLData item = pair.getInput();

      final StringBuilder line = new StringBuilder();

      NumberList.toList(CSVFormat.EG_FORMAT, line, item.getData());
      line.insert(0, "new double[] { ");
      line.append(" },");
      addLine(line.toString());
    }
    unIndentLine("};");

    addBreak();

    // generate the ideal data

    indentLine("public static readonly double[][] IDEAL_DATA = {");
    for (final MLDataPair pair : data) {
      final MLData item = pair.getIdeal();

      final StringBuilder line = new StringBuilder();

      NumberList.toList(CSVFormat.EG_FORMAT, line, item.getData());
      line.insert(0, "new double[] { ");
      line.append(" },");
      addLine(line.toString());
    }
    unIndentLine("};");
View Full Code Here

    // generate the input data

    indentLine("var INPUT_DATA = [");
    for (final MLDataPair pair : data) {
      final MLData item = pair.getInput();

      final StringBuilder line = new StringBuilder();

      NumberList.toList(CSVFormat.EG_FORMAT, line, item.getData());
      line.insert(0, "[ ");
      line.append(" ],");
      addLine(line.toString());
    }
    unIndentLine("];");

    addBreak();

    // generate the ideal data

    indentLine("var IDEAL_DATA = [");
    for (final MLDataPair pair : data) {
      final MLData item = pair.getIdeal();

      final StringBuilder line = new StringBuilder();

      NumberList.toList(CSVFormat.EG_FORMAT, line, item.getData());
      line.insert(0, "[ ");
      line.append(" ],");
      addLine(line.toString());
    }
    unIndentLine("];");
View Full Code Here

    // generate the input data

    indentLine("public static final double[][] INPUT_DATA = {");
    for (final MLDataPair pair : data) {
      final MLData item = pair.getInput();

      final StringBuilder line = new StringBuilder();

      NumberList.toList(CSVFormat.EG_FORMAT, line, item.getData());
      line.insert(0, "{ ");
      line.append(" },");
      addLine(line.toString());
    }
    unIndentLine("};");

    addBreak();

    // generate the ideal data

    indentLine("public static final double[][] IDEAL_DATA = {");
    for (final MLDataPair pair : data) {
      final MLData item = pair.getIdeal();

      final StringBuilder line = new StringBuilder();

      NumberList.toList(CSVFormat.EG_FORMAT, line, item.getData());
      line.insert(0, "{ ");
      line.append(" },");
      addLine(line.toString());
    }
    unIndentLine("};");
View Full Code Here

      final MLMethod method) {

    final ReadCSV csv = new ReadCSV(getInputFilename().toString(),
        isExpectInputHeaders(), getFormat());

    MLData output = null;
   
    for (final AnalystField field : analyst.getScript().getNormalize()
        .getNormalizedFields()) {
      field.init();
    }

    final int outputLength = this.analyst.determineTotalInputFieldCount();

    final PrintWriter tw = this.prepareOutputFile(method, outputFile, this.analyst
        .getScript().getNormalize().countActiveFields() - 1, 1);

    resetStatus();
    while (csv.next()) {
      updateStatus(false);
      final LoadedRow row = new LoadedRow(csv, this.outputColumns);

      double[] inputArray = AnalystNormalizeCSV.extractFields(analyst,
          this.analystHeaders, csv, outputLength, true);
      if (this.series.getTotalDepth() > 1) {
        inputArray = this.series.process(inputArray);
      }

      if (inputArray != null) {
        final MLData input = new BasicMLData(inputArray);

        // evaluation data
        if ((method instanceof MLClassification)
            && !(method instanceof MLRegression)) {
          // classification only?
View Full Code Here

          + method.getInputCount()
          + " inputs, however, the data has " + this.inputCount
          + " inputs.");
    }

    MLData output = null;
    final MLData input = new BasicMLData(method.getInputCount());

    final PrintWriter tw = analystPrepareOutputFile(outputFile);

    resetStatus();
    while (csv.next()) {
      updateStatus(false);
      final LoadedRow row = new LoadedRow(csv, this.idealCount);

      int dataIndex = 0;
      // load the input data
      for (int i = 0; i < this.inputCount; i++) {
        final String str = row.getData()[i];
        final double d = getFormat().parse(str);
        input.setData(i, d);
        dataIndex++;
      }

      // do we need to skip the ideal values?
      dataIndex += this.idealCount;
View Full Code Here

    double[] derivative = new double[weightCount];
   
    // Loop over every training element
    for (final MLDataPair pair : this.training) {
      EngineArray.fill(derivative, 0);
      final MLData networkOutput = this.network.compute(pair.getInput());

      e = pair.getIdeal().getData(outputNeuron) - networkOutput.getData(outputNeuron);     
      error.updateError(networkOutput.getData(outputNeuron), pair.getIdeal().getData(outputNeuron));
     
      int currentWeight = 0;
     
      // loop over the output weights
      int outputFeedCount  = network.getLayerTotalNeuronCount(network.getLayerCount()-2);
      for(int i=0;i<this.network.getOutputCount();i++) {
        for(int j=0;j<outputFeedCount;j++) {
          double jc;
         
          if (i == outputNeuron) {
            jc = computeDerivative(pair.getInput(), outputNeuron,
                currentWeight, this.dStep,
                networkOutput.getData(outputNeuron), row);
          } else {
            jc = 0;
          }
     
          this.gradients[currentWeight] += jc *e;
          derivative[currentWeight] = jc;
          currentWeight++;
        }
      }
     
      // Loop over every weight in the neural network
      while( currentWeight<this.network.getFlat().getWeights().length) {
        double jc = computeDerivative(
            pair.getInput(), outputNeuron, currentWeight,
            this.dStep,
            networkOutput.getData(outputNeuron), row);
        derivative[currentWeight] = jc;
        this.gradients[currentWeight] += jc *e;
        currentWeight++;
      }

 
View Full Code Here

    // process the output fields

    initForOutput();

    final MLData result = new BasicMLData(outputCount);

    // write the value
    int outputIndex = 0;
    for (final OutputField ofield : this.outputFields) {
      if (!ofield.isIdeal()) {
        for (int sub = 0; sub < ofield.getSubfieldCount(); sub++) {
          result.setData(outputIndex++, ofield.calculate(sub));
        }
      }
    }

    return result;
View Full Code Here

TOP

Related Classes of org.encog.ml.data.MLData

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.