Package org.encog.ml.data

Examples of org.encog.ml.data.MLDataPair


    dset.setLeadWindowSize(1);
    dset.setLagWindowSize(1);
   
    Assert.assertEquals(8, 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(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(3.0, p2.getInput().getData(1),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(4.0, p3.getInput().getData(1),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(40.0, p3.getIdeal().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
  }
View Full Code Here


    dset.setLeadWindowSize(2);
    dset.setLagWindowSize(1);
   
    Assert.assertEquals(7, 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(20.0, p1.getIdeal().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(30.0, p1.getIdeal().getData(1),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(30.0, p2.getIdeal().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(40.0, p2.getIdeal().getData(1),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(40.0, p3.getIdeal().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(50.0, p3.getIdeal().getData(1),Encog.DEFAULT_DOUBLE_EQUAL);
  }
View Full Code Here

    dset.setLeadWindowSize(1);
    dset.setLagWindowSize(2);
   
    Assert.assertEquals(7, 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(3.0, p1.getInput().getData(2),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(3.0, p2.getInput().getData(1),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(4.0, p2.getInput().getData(2),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(4.0, p3.getInput().getData(1),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(5.0, p3.getInput().getData(2),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(40.0, p3.getIdeal().getData(0),Encog.DEFAULT_DOUBLE_EQUAL);
  }
View Full Code Here

    temporal.generate();
   
    Iterator<MLDataPair> itr = temporal.iterator();
   
    // set 0
    MLDataPair pair = itr.next();
    TestCase.assertEquals(10, pair.getInput().size());
    TestCase.assertEquals(1, pair.getIdeal().size());
    TestCase.assertEquals(0.75, Math.round(pair.getInput().getData(0)*4.0)/4.0);
    TestCase.assertEquals(1.0, Math.round(pair.getInput().getData(1)*4.0)/4.0);
    TestCase.assertEquals(1.0, Math.round(pair.getInput().getData(2)*4.0)/4.0);
    TestCase.assertEquals(1.0, Math.round(pair.getInput().getData(3)*4.0)/4.0);

  }
 
View Full Code Here

      MLDataSet result = new BasicMLDataSet();
      for(int i=0;i<count;i++) {
        for(int j=0;j<4;j++) {
          MLData inputData = new BasicMLData(XOR_INPUT[j]);
          MLData idealData = new BasicMLData(XOR_IDEAL[j]);
          MLDataPair pair = new BasicMLDataPair(inputData,idealData);
          inputData.setData(0, inputData.getData(0)+RangeRandomizer.randomize(-0.1, 0.1));
          inputData.setData(1, inputData.getData(1)+RangeRandomizer.randomize(-0.1, 0.1));
          result.add(pair);
        }
      }
View Full Code Here

                             
        int i = 1;
        for(MLCluster cluster: kmeans.getClusters())
        {
          MLDataSet ds = cluster.createDataSet();
            MLDataPair pair = BasicMLDataPair.createPair(ds.getInputSize(), ds.getIdealSize());
            ds.getRecord(0, pair);
          double t = pair.getInputArray()[0];
         
            for(int j=0;j<ds.getRecordCount();j++)
            {
              ds.getRecord(j, pair);
             
              for(j=0;j<pair.getInputArray().length;j++) {
                if(t>10) {
                  Assert.assertTrue(pair.getInputArray()[j]>10);
                } else {
                  Assert.assertTrue(pair.getInputArray()[j]<10);
                }
              }
             
            }
           
View Full Code Here

    float[] data = { 1,2,3,4,5 };
   
    AutoFloatDataSet set = new AutoFloatDataSet(1,1,2,1)
    set.addColumn(data);
    set.addColumn(data);
    MLDataPair pair;
   
    Assert.assertEquals(3, set.size());
   
    pair = set.get(0);
    System.out.println(pair);
    Assert.assertEquals(1, pair.getInputArray()[0],Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(2, pair.getInputArray()[1],Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(3, pair.getIdealArray()[0],Encog.DEFAULT_DOUBLE_EQUAL);
   
    pair = set.get(1);
    System.out.println(pair);
    Assert.assertEquals(2, pair.getInputArray()[0],Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(3, pair.getInputArray()[1],Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(4, pair.getIdealArray()[0],Encog.DEFAULT_DOUBLE_EQUAL);
   
    pair = set.get(2);
    System.out.println(pair);
    Assert.assertEquals(3, pair.getInputArray()[0],Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(4, pair.getInputArray()[1],Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals(5, pair.getIdealArray()[0],Encog.DEFAULT_DOUBLE_EQUAL);
   
    System.out.println( set.size());
   
    pair = set.get(3);
    Assert.assertNull(pair);
View Full Code Here

    TestCase.assertEquals(10, temporal.calculateActualSetSize());
   
    Iterator<MLDataPair> itr = temporal.iterator();
   
    // set 0
    MLDataPair pair = itr.next();
    TestCase.assertEquals(10, pair.getInput().size());
    TestCase.assertEquals(1, pair.getIdeal().size());
    TestCase.assertEquals(1.0, pair.getInput().getData(0));
    TestCase.assertEquals(2.0, pair.getInput().getData(1));
    TestCase.assertEquals(4.0, pair.getInput().getData(2));
    TestCase.assertEquals(5.0, pair.getInput().getData(3));
    TestCase.assertEquals(7.0, pair.getInput().getData(4));
    TestCase.assertEquals(8.0, pair.getInput().getData(5));
    TestCase.assertEquals(10.0, pair.getInput().getData(6));
    TestCase.assertEquals(11.0, pair.getInput().getData(7));
    TestCase.assertEquals(13.0, pair.getInput().getData(8));
    TestCase.assertEquals(14.0, pair.getInput().getData(9));
    TestCase.assertEquals(18.0, pair.getIdeal().getData(0));
   
    // set 1
    pair = itr.next();
    TestCase.assertEquals(10, pair.getInput().size());
    TestCase.assertEquals(1, pair.getIdeal().size());
    TestCase.assertEquals(4.0, pair.getInput().getData(0));
    TestCase.assertEquals(5.0, pair.getInput().getData(1));
    TestCase.assertEquals(7.0, pair.getInput().getData(2));
    TestCase.assertEquals(8.0, pair.getInput().getData(3));
    TestCase.assertEquals(10.0, pair.getInput().getData(4));
    TestCase.assertEquals(11.0, pair.getInput().getData(5));
    TestCase.assertEquals(13.0, pair.getInput().getData(6));
    TestCase.assertEquals(14.0, pair.getInput().getData(7));
    TestCase.assertEquals(16.0, pair.getInput().getData(8));
    TestCase.assertEquals(17.0, pair.getInput().getData(9));
    TestCase.assertEquals(21.0, pair.getIdeal().getData(0));
   
    // set 2
    pair = itr.next();
    TestCase.assertEquals(10, pair.getInput().size());
    TestCase.assertEquals(1, pair.getIdeal().size());
    TestCase.assertEquals(7.0, pair.getInput().getData(0));
    TestCase.assertEquals(8.0, pair.getInput().getData(1));
    TestCase.assertEquals(10.0, pair.getInput().getData(2));
    TestCase.assertEquals(11.0, pair.getInput().getData(3));
    TestCase.assertEquals(13.0, pair.getInput().getData(4));
    TestCase.assertEquals(14.0, pair.getInput().getData(5));
    TestCase.assertEquals(16.0, pair.getInput().getData(6));
    TestCase.assertEquals(17.0, pair.getInput().getData(7));
    TestCase.assertEquals(19.0, pair.getInput().getData(8));
    TestCase.assertEquals(20.0, pair.getInput().getData(9));
    TestCase.assertEquals(24.0, pair.getIdeal().getData(0));
   
    // set 3
    pair = itr.next();
    TestCase.assertEquals(10, pair.getInput().size());
    TestCase.assertEquals(1, pair.getIdeal().size());
    TestCase.assertEquals(10.0, pair.getInput().getData(0));
    TestCase.assertEquals(11.0, pair.getInput().getData(1));
    TestCase.assertEquals(13.0, pair.getInput().getData(2));
    TestCase.assertEquals(14.0, pair.getInput().getData(3));
    TestCase.assertEquals(16.0, pair.getInput().getData(4));
    TestCase.assertEquals(17.0, pair.getInput().getData(5));
    TestCase.assertEquals(19.0, pair.getInput().getData(6));
    TestCase.assertEquals(20.0, pair.getInput().getData(7));
    TestCase.assertEquals(22.0, pair.getInput().getData(8));
    TestCase.assertEquals(23.0, pair.getInput().getData(9));
    TestCase.assertEquals(27.0, pair.getIdeal().getData(0));
   
    TestCase.assertNull(itr.next());
  }
View Full Code Here

    TestCase.assertEquals(7, temporal.calculateActualSetSize());
   
    Iterator<MLDataPair> itr = temporal.iterator();
   
    // set 0
    MLDataPair pair = itr.next();
    TestCase.assertEquals(10, pair.getInput().size());
    TestCase.assertEquals(1, pair.getIdeal().size());
    TestCase.assertEquals(7.0, pair.getInput().getData(0));
    TestCase.assertEquals(8.0, pair.getInput().getData(1));
    TestCase.assertEquals(10.0, pair.getInput().getData(2));
    TestCase.assertEquals(11.0, pair.getInput().getData(3));
    TestCase.assertEquals(13.0, pair.getInput().getData(4));
    TestCase.assertEquals(14.0, pair.getInput().getData(5));
    TestCase.assertEquals(16.0, pair.getInput().getData(6));
    TestCase.assertEquals(17.0, pair.getInput().getData(7));
    TestCase.assertEquals(19.0, pair.getInput().getData(8));
    TestCase.assertEquals(20.0, pair.getInput().getData(9));
    TestCase.assertEquals(24.0, pair.getIdeal().getData(0));
   
    // only one set
    TestCase.assertNull(itr.next());
  }
View Full Code Here

 
  private FoldedDataSet performFoldTest(int recordCount, int foldCount, int testIndex1, int testCount1, int testIndex2, int testCount2) {
    MLDataSet dataSet = new BasicMLDataSet();
   
    for(int i=0;i<recordCount;i++) {
      final MLDataPair pair = BasicMLDataPair.createPair(4,1);
      pair.getIdeal().setData(0, i);
      dataSet.add(pair);
    }
   
    FoldedDataSet foldedData = new FoldedDataSet(dataSet);
    foldedData.fold(foldCount);
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.