Examples of MLData


Examples of org.encog.ml.data.MLData

   * Compute the outstar layer.
   * @param input The input.
   * @return The output.
   */
  public final MLData computeOutstar(final MLData input) {
    final MLData result = new BasicMLData(this.outstarCount);

    double sum = 0;

    for (int i = 0; i < this.outstarCount; i++) {
      sum = 0;
      for (int j = 0; j < this.instarCount; j++) {
        sum += this.weightsInstarToOutstar.get(j, i) * input.getData(j);
      }
      result.setData(i, sum);
    }
    return result;
  }
View Full Code Here

Examples of org.encog.ml.data.MLData

    }

    double worstDistance = Double.NEGATIVE_INFINITY;

    for (final MLDataPair pair : this.training) {
      final MLData out = this.network.computeInstar(pair.getInput());

      // determine winner
      final int winner = EngineArray.indexOfLargest(out.getData());

      // calculate the distance
      double distance = 0;
      for (int i = 0; i < pair.getInput().size(); i++) {
        final double diff = pair.getInput().getData(i)
View Full Code Here

Examples of org.encog.ml.data.MLData

                "Please enter a valid input number.");
          }
          input.setData(i, value);
        }

        final MLData output = getData().compute(input);

        for (int i = 0; i < this.outputCount; i++) {
          this.outputTable.setValueAt(output.getData(i), i, 1);
        }
      } catch (EncogError ex) {
        EncogWorkBench.displayError("Query Error", ex.getMessage());
      } catch (Throwable t) {
        ErrorDialog.handleError(t,this.getEncogObject(), null);
View Full Code Here

Examples of org.encog.ml.data.MLData

    }

    final ErrorCalculation error = new ErrorCalculation();

    for (final MLDataPair pair : this.training) {
      final MLData out = this.network.computeInstar(pair.getInput());

      final int j = EngineArray.indexOfLargest(out.getData());
      for (int i = 0; i < this.network.getOutstarCount(); i++) {
        final double delta = this.learningRate
            * (pair.getIdeal().getData(i) - this.network
                .getWeightsInstarToOutstar().get(j, i));
        this.network.getWeightsInstarToOutstar().add(j, i, delta);
      }

      final MLData out2 = this.network.computeOutstar(out);
      error.updateError(out2.getData(), pair.getIdeal().getData(), pair.getSignificance());
    }

    setError(error.calculate());
  }
View Full Code Here

Examples of org.encog.ml.data.MLData

  public void performQuery() {
    try {
      int outputCount = ((MLOutput) method).getOutputCount();
      boolean[] grid = this.panel.getGrid();
      MLData input = new BasicMLData(grid.length);
      for (int i = 0; i < grid.length; i++) {
        input.setData(i, grid[i] ? 1 : -1);
      }

      if (classification) {
        int output = ((MLClassification) this.method).classify(input);
        this.outputTable.setValueAt(output, 0, 1);
      } else {
        MLData output = ((MLRegression) this.method).compute(input);
        for (int i = 0; i < outputCount; i++) {
          this.outputTable.setValueAt(output.getData(i), i, 1);
        }
      }
    } catch (EncogError ex) {
      EncogWorkBench.displayError("Query Error", ex.getMessage());
    } catch (Throwable t) {
View Full Code Here

Examples of org.encog.ml.data.MLData

  /**
   * {@inheritDoc}
   */
  @Override
  public final MLData compute(final MLData input) {
    final MLData output = new BasicMLData(getOutputCount());
    this.flat.compute(input.getData(), output.getData());
    return output;
  }
View Full Code Here

Examples of org.encog.ml.data.MLData

    System.out.println("Year\tActual\tPredict\tClosed Loop Predict");
   
    for(int year=EVALUATE_START;year<EVALUATE_END;year++)
    {
      // calculate based on actual data
      MLData input = new BasicMLData(WINDOW_SIZE);
      for(int i=0;i<input.size();i++)
      {
        input.setData(i,this.normalizedSunspots[(year-WINDOW_SIZE)+i]);
      }
      MLData output = network.compute(input);
      double prediction = output.getData(0);
      this.closedLoopSunspots[year] = prediction;
     
      // calculate "closed loop", based on predicted data
      for(int i=0;i<input.size();i++)
      {
        input.setData(i,this.closedLoopSunspots[(year-WINDOW_SIZE)+i]);
      }
      output = network.compute(input);
      double closedLoopPrediction = output.getData(0);
     
      // display
      System.out.println((STARTING_YEAR+year)
          +"\t"+f.format(this.normalizedSunspots[year])
          +"\t"+f.format(prediction)
View Full Code Here

Examples of org.encog.ml.data.MLData

    System.out.println("Year\tActual\tPredict\tClosed Loop Predict");
   
    for(int year=EVALUATE_START;year<EVALUATE_END;year++)
    {
      // calculate based on actual data
      MLData input = new BasicMLData(WINDOW_SIZE);
      for(int i=0;i<input.size();i++)
      {
        input.setData(i,this.normalizedSunspots[(year-WINDOW_SIZE)+i]);
      }
      MLData output = network.compute(input);
      double prediction = output.getData(0);
      this.closedLoopSunspots[year] = prediction;
     
      // calculate "closed loop", based on predicted data
      for(int i=0;i<input.size();i++)
      {
        input.setData(i,this.closedLoopSunspots[(year-WINDOW_SIZE)+i]);
      }
      output = network.compute(input);
      double closedLoopPrediction = output.getData(0);
     
      // display
      System.out.println((STARTING_YEAR+year)
          +"\t"+f.format(this.normalizedSunspots[year])
          +"\t"+f.format(prediction)
View Full Code Here

Examples of org.encog.ml.data.MLData

      throw new EncogError(
          "Can't use the SVM yet, it has not been trained, "
          + "and no model exists.");
    }

    final MLData result = new BasicMLData(1);

    final svm_node[] formattedInput = makeSparse(input);

    final double d = svm.svm_predict(this.model, formattedInput);
    result.setData(0, d);

    return result;
  }
View Full Code Here

Examples of org.encog.ml.data.MLData

   *            The training set to evaluate.
   */
  public static void evaluate(final MLRegression network,
      final MLDataSet training) {
    for (final MLDataPair pair : training) {
      final MLData output = network.compute(pair.getInput());
      System.out.println("Input="
          + EncogUtility.formatNeuralData(pair.getInput())
          + ", Actual=" + EncogUtility.formatNeuralData(output)
          + ", Ideal="
          + EncogUtility.formatNeuralData(pair.getIdeal()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.