Package org.encog.ml.data

Examples of org.encog.ml.data.MLDataPair


  @Override
  public int getInputSize() {
    if (this.data.isEmpty()) {
      return 0;
    }
    final MLDataPair first = this.data.get(0);
    return first.getInput().size();
  }
View Full Code Here


   * {@inheritDoc}
   */
  @Override
  public void getRecord(final long index, final MLDataPair pair) {

    final MLDataPair source = this.data.get((int) index);
    pair.setInputArray(source.getInputArray());
    if (pair.getIdealArray() != null) {
      pair.setIdealArray(source.getIdealArray());
    }

  }
View Full Code Here

          double d = csv.getDouble(index++);
          ideal.setData(i, d);
        }
      }

      MLDataPair pair = new BasicMLDataPair(input, ideal);
      result.add(pair);
    }

    return result;
  }
View Full Code Here

        if (series.getTotalDepth() > 1) {
          output = series.process(output);
        }

        MLDataPair pair = BasicMLDataPair.createPair(inputCount,outputCount);
        for(int i=0;i<inputCount;i++) {
          pair.getInput().setData(i, output[i]);
        }
        for(int i=0;i<outputCount;i++) {
          pair.getIdeal().setData(i, output[i+inputCount]);
        }
        result.add(pair);
      }
      return result;
    } finally {
View Full Code Here

   */
  public double calculateError(final MLDataSet data) {
    final ErrorCalculation errorCalculation = new ErrorCalculation();

    final double[] actual = new double[this.outputCount];
    final MLDataPair pair = BasicMLDataPair.createPair(data.getInputSize(),
        data.getIdealSize());

    for (int i = 0; i < data.getRecordCount(); i++) {
      data.getRecord(i, pair);
      compute(pair.getInputArray(), actual);
      errorCalculation.updateError(actual, pair.getIdealArray(), pair.getSignificance());
    }
    return errorCalculation.calculate();
  }
View Full Code Here

            inputData.setData(i,
                CSVFormat.EG_FORMAT.parse(cols.get(index++)));
          }
          final MLData idealData = new BasicMLData(outputCount);
          idealData.setData(0,CSVFormat.EG_FORMAT.parse(cols.get(index++)));
          final MLDataPair pair = new BasicMLDataPair(inputData,idealData);
          samples.add(pair);
        }
      }
    }
View Full Code Here

    BasicMLData ideal = new BasicMLData(1);
    ImageMLData input = new ImageMLData(image);
    set.add(input,ideal);
    set.downsample(2,2);
    Iterator<MLDataPair> itr = set.iterator();
    MLDataPair pair = (MLDataPair)itr.next();
    MLData data = pair.getInput();
    double[] d = data.getData();
    //Assert.assertEquals(d[0],-1.0, 0.1);
    //Assert.assertEquals(d[5],1, 0.1);
   
    // just "flex" these for no exceptions
View Full Code Here

  }

  private double getWeightedError(GenericEnsembleML newML, MLDataSet dataSet) {
    double sum = 0;
    for (int i = 0; i < dataSet.size(); i++) {
      MLDataPair currentData = dataSet.get(i);
      if (newML.classify(currentData.getInput()) != newML.winner(currentData.getIdeal()))
        sum += currentData.getSignificance();
    }
    return sum;
  }
View Full Code Here

    MatrixMLDataSet dset = new MatrixMLDataSet(DATA1,1,1);
    dset.setLeadWindowSize(1);
   
    Assert.assertEquals(9, dset.size());
   
    MLDataPair p1 = dset.get(0);
    Assert.assertEquals(1.0, p1.getInput().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(20.0, p1.getIdeal().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
   
    MLDataPair p2 = dset.get(1);
    Assert.assertEquals(2.0, p2.getInput().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(30.0, p2.getIdeal().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
   
    MLDataPair p3 = dset.get(2);
    Assert.assertEquals(3.0, p3.getInput().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(40.0, p3.getIdeal().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
  }
View Full Code Here

    MatrixMLDataSet dset = new MatrixMLDataSet(DATA1,1,1);
    dset.setLagWindowSize(1);
   
    Assert.assertEquals(9, dset.size());
   
    MLDataPair p1 = dset.get(0);
    Assert.assertEquals(1.0, p1.getInput().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(2.0, p1.getInput().getData(1),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(10.0, p1.getIdeal().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
   
    MLDataPair p2 = dset.get(1);
    Assert.assertEquals(2.0, p2.getInput().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(3.0, p2.getInput().getData(1),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(20.0, p2.getIdeal().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
   
    MLDataPair p3 = dset.get(2);
    Assert.assertEquals(3.0, p3.getInput().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(4.0, p3.getInput().getData(1),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(30.0, p3.getIdeal().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
  }
View Full Code Here

TOP

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

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.