Package org.encog.ml.data

Examples of org.encog.ml.data.MLData


  public int scorePilot()
  {
    LanderSimulator sim = new LanderSimulator();
    while(sim.flying())
    {
      MLData input = new BasicMLData(3);
            input.setData(0, this.fuelStats.normalize(sim.getFuel()));
            input.setData(1, this.fuelStats.normalize(sim.getAltitude()));
            input.setData(2, this.fuelStats.normalize(sim.getVelocity()));
            MLData output = this.network.compute(input);
            double value = output.getData(0);

            boolean thrust;
     
      if( value > 0 )
      {
View Full Code Here


    Vector<String> tableHeaders = null;

    int key = 0;
    Vector<String> tableDataRow;
    for (MLDataPair dataRow : validationData) {
      MLData input = dataRow.getInput();
      MLData validIdeal = dataRow.getIdeal();
      MLData computatedIdeal = getCalculatedResult(dataRow, method);
      int inputCount = input.size();
      int idealCount = validIdeal == null ? 0 : validIdeal.size();

      tableDataRow = new Vector<String>();
      if (tableHeaders == null) {
        tableHeaders = new Vector<String>();
        for (int i = 0; i < inputCount; i++) {
          tableHeaders.add("Input " + i);
        }
        for (int i = 0; i < computatedIdeal.size(); i++) {
          tableHeaders.add("Ideal " + i);
          tableHeaders.add("Result " + i);
        }
      }

      for (int i = 0; i < inputCount; i++) {
        tableDataRow.add(new Double(input.getData(i)).toString());
      }

      for (int i = validation.size(); i < idealCount; i++) {
        validation.add(new XYSeries("Validation"));
        computation.add(new XYSeries("Computation"));
        createChart();
      }

      for (int i = 0; i < computatedIdeal.size(); i++) {
        double c = computatedIdeal.getData(i);
               
        if (idealCount > 0) {
          double v = validIdeal.getData(i);
          validation.get(i).add(key, v);
          tableDataRow.add(new Double(v).toString());
View Full Code Here

    tabs.addTab("Data", new JScrollPane(table));
  }

  private MLData getCalculatedResult(MLDataPair data, MLMethod method) {

    MLData out;

    if (method instanceof MLRegression) {
      out = ((MLRegression) method).compute(data.getInput());
    } else if (method instanceof MLClassification) {
      out = new BasicMLData(1);
      out.setData(0,
          ((MLClassification) method).classify(data.getInput()));

    } else {
      throw new WorkBenchError("Unsupported Machine Learning Method:"
          + method.getClass().getSimpleName());
View Full Code Here

          + method.getInputCount()
          + " inputs, however, the data has " + this.inputCount
          + " inputs.");
    }

    MLData output = null;
    final MLData input = new BasicMLData(method.getInputCount());

    final PrintWriter tw = analystPrepareOutputFile(outputFile);

    resetStatus();
    while (csv.next()) {
      updateStatus(false);
      final LoadedRow row = new LoadedRow(csv, this.idealCount);

      int dataIndex = 0;
      // load the input data
      for (int i = 0; i < this.inputCount; i++) {
        final String str = row.getData()[i];
        final double d = getInputFormat().parse(str);
        input.setData(i, d);
        dataIndex++;
      }

      // do we need to skip the ideal values?
      dataIndex += this.idealCount;
View Full Code Here

    for (iteration = 0; iteration <= 100; iteration++) {
      train.iteration();
    }

    final MLData data1 = new BasicMLData(
        TestCompetitive.SOM_INPUT[0]);
    final MLData data2 = new BasicMLData(
        TestCompetitive.SOM_INPUT[1]);
   
    int result1 = network.winner(data1);
    int result2 = network.winner(data2);
   
View Full Code Here

      final MLMethod method) {

    final ReadCSV csv = new ReadCSV(getInputFilename().toString(),
        isExpectInputHeaders(), getInputFormat());

    MLData output = null;

    final int outputLength = this.analyst.determineUniqueColumns();

    final PrintWriter tw = this.prepareOutputFile(outputFile, this.analyst
        .getScript().getNormalize().countActiveFields() - 1, 1);

    resetStatus();
    while (csv.next()) {
      updateStatus(false);
      final LoadedRow row = new LoadedRow(csv, this.outputColumns);

      double[] inputArray = AnalystNormalizeCSV.extractFields(analyst,
          this.analystHeaders, csv, outputLength, false);
      if (this.series.getTotalDepth() > 1) {
        inputArray = this.series.process(inputArray);
      }

      if (inputArray != null) {
        final MLData input = new BasicMLData(inputArray);

        // evaluation data
        if ((method instanceof MLClassification)
            && !(method instanceof MLRegression)) {
          // classification only?
View Full Code Here

  public int scorePilot()
  {
    LanderSimulator sim = new LanderSimulator();
    while(sim.flying())
    {
      MLData input = new BasicMLData(3);
            input.setData(0, this.fuelStats.normalize(sim.getFuel()));
            input.setData(1, this.altitudeStats.normalize(sim.getAltitude()));
            input.setData(2, this.velocityStats.normalize(sim.getVelocity()));
            MLData output = this.network.compute(input);
            double value = output.getData(0);

            boolean thrust;
     
      if( value > 0 )
      {
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
      System.out.println((STARTING_YEAR+year)
          +"\t"+f.format(this.normalizedSunspots[year])
          +"\t"+f.format(prediction)
View Full Code Here

        }
    }
    private Object getNeuralNetworkTrainingData(NeuralData nd){
        MLDataSet trainingSet=new BasicMLDataSet();
       
        MLData mdInput=new BasicMLData(nd.getInputVector());
        MLData mdOuput=new BasicMLData(nd.getOutputVector());
       
               
        trainingSet.add(mdInput, mdOuput);
       
        return trainingSet;
View Full Code Here

       
        return trainingSet;
    }
   
    private Object getNeuralNetworkTrainingData(NeuralData nd,MLDataSet trainingSet){
        MLData mdInput=new BasicMLData(nd.getInputVector());
        MLData mdOuput=new BasicMLData(nd.getOutputVector());
       
               
        trainingSet.add(mdInput, mdOuput);
       
        return trainingSet;
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.