Package org.encog.ml.data.basic

Examples of org.encog.ml.data.basic.BasicMLData


  public void actionPerformed(final ActionEvent e) {
    if (e.getSource() == this.calculateButton) {
      try {
        setDirty(true);
        final BasicMLData input = new BasicMLData(
            this.inputCount);
        for (int i = 0; i < this.inputCount; i++) {
          double value = 0;
          final String str = (String) this.inputTable
              .getValueAt(i, 1);
          try {
            value = Double.parseDouble(str);
          } catch (final NumberFormatException e2) {
            EncogWorkBench.displayError("Data Error",
                "Please enter a valid input number.");
          }
          input.setData(i, value);
        }

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

        for (int i = 0; i < this.outputCount; i++) {
View Full Code Here


  public void actionPerformed(final ActionEvent e) {
    if (e.getSource() == this.calculateButton) {
      try {
        setDirty(true);
        final BasicMLData input = new BasicMLData(
            this.inputCount);
        for (int i = 0; i < this.inputCount; i++) {
          double value = 0;
          final String str = (String) this.inputTable
              .getValueAt(i, 1);
          try {
            value = Double.parseDouble(str);
          } catch (final NumberFormatException e2) {
            EncogWorkBench.displayError("Data Error",
                "Please enter a valid input number.");
          }
          input.setData(i, value);
        }

        final int output = getData().classify(input);

        this.outputTable.setValueAt(output, 0, 1);
View Full Code Here

  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);
View Full Code Here

  /**
   * {@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

    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
View Full Code Here

    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
View Full Code Here

      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

      
       BufferedNeuralDataSet buffer = new BufferedNeuralDataSet(binFile);
       buffer.beginLoad(input.length, ideal.length);
       while(csv.next())
       {
         BasicMLData inputData = new BasicMLData(input.length);
         BasicMLData idealData = new BasicMLData(ideal.length);
        
         // handle input data
         for(int i=0;i<input.length;i++) {
           inputData.setData(i, csv.getDouble(input[i]));
         }
        
         // handle input data
         for(int i=0;i<ideal.length;i++) {
           idealData.setData(i, csv.getDouble(ideal[i]));
         }
        
         // add to dataset
        
           buffer.add(inputData,idealData);
View Full Code Here

  public static void main(final String args[]) {

    final BasicMLDataSet set = new BasicMLDataSet();

    for (final double[] element : SimpleKMeans.DATA) {
      set.add(new BasicMLData(element));
    }

    final KMeansClustering kmeans = new KMeansClustering(2, set);

    kmeans.iteration(100);
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);
View Full Code Here

TOP

Related Classes of org.encog.ml.data.basic.BasicMLData

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.