Package org.encog.ml.data

Examples of org.encog.ml.data.MLData


    final ErrorCalculation errorCalculation = new ErrorCalculation();
    if( method instanceof MLContext )
      ((MLContext)method).clearContext();

    for (final MLDataPair pair : data) {
      final MLData actual = method.compute(pair.getInput());
      errorCalculation.updateError(actual.getData(), pair.getIdeal()
          .getData(),pair.getSignificance());
    }
    return errorCalculation.calculate();
  }
View Full Code Here


      ((MLContext)method).clearContext();
    }

    // calculate error
    for (final MLDataPair pair : data) {
      final MLData actual = method.compute(pair.getInput());
      errorCalculation.updateError(actual.getData(), pair.getIdeal()
          .getData(),pair.getSignificance());
    }
    return errorCalculation.calculate();
  }
View Full Code Here

    // loop over all clusters
    for (final KMeansCluster element : this.clusters) {
      for (int k = 0; k < element.size(); k++) {

        final MLData data = element.get(k);
        double distance = KMeansClustering.calculateEuclideanDistance(
            element.getCentroid(), data);
        KMeansCluster tempCluster = null;
        boolean match = false;
View Full Code Here

  public void run() {

    List<MLData> samples = new ArrayList<MLData>();
    for (int i = 0; i < 15; i++) {
      MLData data = new BasicMLData(3);
      data.setData(0, RangeRandomizer.randomize(-1, 1));
      data.setData(1, RangeRandomizer.randomize(-1, 1));
      data.setData(2, RangeRandomizer.randomize(-1, 1));
      samples.add(data);
    }

    this.train.setAutoDecay(1000, 0.8, 0.003, 30, 5);

    for (int i = 0; i < 1000; i++) {
      int idx = (int) (Math.random() * samples.size());
      MLData c = samples.get(idx);

      this.train.trainPattern(c);
      this.train.autoDecay();
      this.map.repaint();
      System.out.println("Iteration " + i + "," + this.train.toString());
View Full Code Here

        PrintWriter out = new PrintWriter(outFile);
       
       
            for (MLDataPair pair : trainingSet)
            {
                MLData output = network.compute(pair.getInput());
                //1D//sw.WriteLine(InverseScale(pair.Input[0]) + ", " + Chop(InverseScale(output[0])));// + ", " + pair.Ideal[0]);
                out.println(inverseScale(pair.getInputArray()[0]) + ", " + inverseScale(pair.getInputArray()[1]) + ", " + chop(inverseScale(output.getData(0))));// + ", " + pair.Ideal[0]);// + ",ideal=" + pair.Ideal[0]);
                //3D//sw.WriteLine(InverseScale(pair.Input[0]) + ", " + InverseScale(pair.Input[1]) + ", " + InverseScale(pair.Input[2]) + ", " + Chop(InverseScale(output[0])));// + ", " + pair.Ideal[0]);// + ",ideal=" + pair.Ideal[0]);
                //Console.WriteLine(pair.Input[0] + ", actual=" + output[0] + ",ideal=" + pair.Ideal[0]);
            }
            out.close();
View Full Code Here

    return Math.sin(rad);
  }
 
  public double obtainPrediction(int angle)
  {
    MLData input = new BasicMLData(PredictSIN.INPUT_WINDOW);
    if( angle< PredictSIN.INPUT_WINDOW )
      return this.predict[angle];
   
    int index = angle - PredictSIN.INPUT_WINDOW;
    for(int i=0;i<PredictSIN.INPUT_WINDOW;i++)
    {
      input.setData(i,this.actual[index++]);
    }
   
    MLData output = this.network.compute(input);
    return output.getData(0);
   
   
  }
View Full Code Here

    for(int i=0;i<DIGITS.length;i++)
    {     
      BasicMLData ideal = new BasicMLData(DIGITS.length);
     
      // setup input
      MLData input = image2data(DIGITS[i]);
     
      // setup ideal
      for(int j=0;j<DIGITS.length;j++)
      {
        if( j==i )
View Full Code Here

    return result;
  }
 
  public static MLData image2data(String[] image)
  {
    MLData result = new BasicMLData(CHAR_WIDTH*CHAR_HEIGHT);
   
    for(int row = 0; row<CHAR_HEIGHT; row++)
    {
      for(int col = 0; col<CHAR_WIDTH; col++)
      {
        int index = (row*CHAR_WIDTH) + col;
        char ch = image[row].charAt(col);
        result.setData(index,ch=='O'?1:-1 );
      }
    }
   
    return result;
  }
View Full Code Here

  public static MLDataSet loadCSVTOMemory(CSVFormat format,
      String filename, boolean headers, int inputSize, int idealSize) {
    MLDataSet result = new BasicMLDataSet();
    ReadCSV csv = new ReadCSV(filename, headers, format);
    while (csv.next()) {
      MLData input = null;
      MLData ideal = null;
      int index = 0;

      input = new BasicMLData(inputSize);
      for (int i = 0; i < inputSize; i++) {
        double d = csv.getDouble(index++);
        input.setData(i, d);
      }

      if (idealSize > 0) {
        ideal = new BasicMLData(idealSize);
        for (int i = 0; i < idealSize; i++) {
          double d = csv.getDouble(index++);
          ideal.setData(i, d);
        }
      }

      MLDataPair pair = new BasicMLDataPair(input, ideal);
      result.add(pair);
View Full Code Here

      result.x = new svm_node[result.l][training.getInputSize()];

      int elementIndex = 0;

      for (final MLDataPair pair : training) {
        final MLData input = pair.getInput();
        final MLData output = pair.getIdeal();
        result.x[elementIndex] = new svm_node[input.size()];

        for (int i = 0; i < input.size(); i++) {
          result.x[elementIndex][i] = new svm_node();
          result.x[elementIndex][i].index = i + 1;
          result.x[elementIndex][i].value = input.getData(i);
        }

        result.y[elementIndex] = output.getData(outputIndex);

        elementIndex++;
      }

      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.