Package org.encog.mathutil.error

Examples of org.encog.mathutil.error.ErrorCalculation


 
  /**
   * Process training for pure batch mode (one single batch).
   */
  protected void processPureBatch() {
    final ErrorCalculation errorCalc = new ErrorCalculation();
    this.visited.clear();

    for (final MLDataPair pair : this.training) {
      final MLData input = pair.getInput();
      final MLData ideal = pair.getIdeal();
      final MLData actual = this.network.compute(input);
      final double sig = pair.getSignificance();

      errorCalc.updateError(actual.getData(), ideal.getData(), sig);

      for (int i = 0; i < this.network.getOutputCount(); i++) {
        final double diff = (ideal.getData(i) - actual.getData(i))
            * sig;
        final FreeformNeuron neuron = this.network.getOutputLayer()
            .getNeurons().get(i);
        calculateOutputDelta(neuron, diff);
        calculateNeuronGradient(neuron);
      }
    }

    // Set the overall error.
    setError(errorCalc.calculate());
   
    // Learn for all data.
    learn();   
  }
View Full Code Here


  /**
   * Process training batches.
   */
  protected void processBatches() {
    int lastLearn = 0;
    final ErrorCalculation errorCalc = new ErrorCalculation();
    this.visited.clear();

    for (final MLDataPair pair : this.training) {
      final MLData input = pair.getInput();
      final MLData ideal = pair.getIdeal();
      final MLData actual = this.network.compute(input);
      final double sig = pair.getSignificance();

      errorCalc.updateError(actual.getData(), ideal.getData(), sig);

      for (int i = 0; i < this.network.getOutputCount(); i++) {
        final double diff = (ideal.getData(i) - actual.getData(i))
            * sig;
        final FreeformNeuron neuron = this.network.getOutputLayer()
            .getNeurons().get(i);
        calculateOutputDelta(neuron, diff);
        calculateNeuronGradient(neuron);
      }
     
      // Are we at the end of a batch.
      lastLearn++;
      if( lastLearn>=this.batchSize ) {
        lastLearn = 0;
        learn()
      }
    }
   
    // Handle any remaining data.
    if( lastLearn>0 ) {
      learn();
    }

    // Set the overall error.
    setError(errorCalc.calculate());
   
  }
View Full Code Here

   }

  public static double calculateRegressionError(MLRegression method,
      MLDataSet data) {
   
    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

        {1,2,3,5},
        {5,6,7,8},
        {9,10,11,12},
        {13,14,15,16} };
   
    ErrorCalculation error = new ErrorCalculation();
   
    for(int i=0;i<ideal.length;i++)
    {
      error.updateError(actual_good[i], ideal[i], 1.0);
    }
    TestCase.assertEquals(0.0,error.calculateRMS());
   
    error.reset();
   
    for(int i=0;i<ideal.length;i++)
    {
      error.updateError(actual_bad[i], ideal[i], 1.0);
    }
    TestCase.assertEquals(250,(int)(error.calculateRMS()*1000));
   
  }
 
View Full Code Here

   */
  private double evaluate(final svm_parameter param, final svm_problem prob,
      final double[] target) {
    int totalCorrect = 0;

    final ErrorCalculation error = new ErrorCalculation();

    if ((param.svm_type == svm_parameter.EPSILON_SVR)
        || (param.svm_type == svm_parameter.NU_SVR)) {
      for (int i = 0; i < prob.l; i++) {
        final double ideal = prob.y[i];
        final double actual = target[i];
        error.updateError(actual, ideal);
      }
      return error.calculate();
    } else {
      for (int i = 0; i < prob.l; i++) {
        if (target[i] == prob.y[i]) {
          ++totalCorrect;
        }
View Full Code Here

public class CalculateRegressionError {
 
  public static double calculateError(final MLRegression method,
      final MLDataSet data) {
    final ErrorCalculation errorCalculation = new ErrorCalculation();
   
    // clear context
    if( method instanceof MLContext ) {
      ((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

   * {@inheritDoc}
   */
  @Override
  public void iteration() {

    final ErrorCalculation errorCalculation = new ErrorCalculation();

    for (final MLDataPair pair : this.training) {
      // calculate the error
      final MLData output = this.network.compute(pair.getInput());

      for (int currentAdaline = 0; currentAdaline < output.size(); currentAdaline++) {
        final double diff = pair.getIdeal().getData(currentAdaline)
            - output.getData(currentAdaline);

        // weights
        for (int i = 0; i <= this.network.getInputCount(); i++) {
          final double input;

          if (i == this.network.getInputCount()) {
            input = 1.0;
          } else {
            input = pair.getInput().getData(i);
          }

          this.network.addWeight(0, i, currentAdaline,
              this.learningRate * diff * input);
        }
      }

      errorCalculation.updateError(output.getData(), pair.getIdeal()
          .getData(),pair.getSignificance());
    }

    // set the global error
    setError(errorCalculation.calculate());
  }
View Full Code Here

 
  /**
   * @return The SSE error with the current weights.
   */
  private double calculateError() {
    ErrorCalculation result = new ErrorCalculation();
   
    for (int i = 0; i < this.trainingLength; i++) {
      this.indexableTraining.getRecord(i, this.pair);
      final MLData actual = this.network.compute(this.pair.getInput());
      result.updateError(actual.getData(), this.pair.getIdeal().getData(),pair.getSignificance());
    }   
   
    return result.calculateESS();
  }
View Full Code Here

TOP

Related Classes of org.encog.mathutil.error.ErrorCalculation

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.