Package org.encog.ml.data.basic

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


      } while (current.getError(testset) > selectionError);
    }
    if(aggregator.needsTraining()) {
      EnsembleDataSet aggTrainingSet = new EnsembleDataSet(members.size() * aggregatorDataSet.getIdealSize(),aggregatorDataSet.getIdealSize());
      for (MLDataPair trainingInput:aggregatorDataSet) {
        BasicMLData trainingInstance = new BasicMLData(members.size() * aggregatorDataSet.getIdealSize());
        int index = 0;
        for(EnsembleML member:members){
          for(double val:member.compute(trainingInput.getInput()).getData()) {
            trainingInstance.add(index++, val);
          }
        }
        aggTrainingSet.add(trainingInstance,trainingInput.getIdeal());
      }
      aggregator.setTrainingSet(aggTrainingSet);
View Full Code Here


public class Averaging implements EnsembleAggregator {

  @Override
  public MLData evaluate(ArrayList<MLData> outputs) {
    int outputSize = outputs.get(0).size();
    BasicMLData acc = new BasicMLData(outputSize);
    for (MLData out: outputs)
    {
      acc = (BasicMLData) acc.plus(out);
    }

    acc = (BasicMLData) acc.times(1.0 / outputs.size());
    return   acc;

  }
View Full Code Here

public class MajorityVoting implements EnsembleAggregator {

  public MLData evaluate(ArrayList<MLData> outputs, double threshold, double lowValue, double highValue) {
    int outputSize = outputs.get(0).size();
    BasicMLData acc = new BasicMLData(outputSize);
    for (MLData out: outputs)
    {
      MLData thresholdedOut = threshold(out, threshold, lowValue, highValue);
      acc = (BasicMLData) acc.plus(thresholdedOut);
    }

    acc = (BasicMLData) acc.times(1.0 / outputs.size());
    return threshold(acc, threshold, lowValue, highValue);
  }
View Full Code Here

    acc = (BasicMLData) acc.times(1.0 / outputs.size());
    return threshold(acc, threshold, lowValue, highValue);
  }
 
  private MLData threshold(MLData d, double threshold, double lowValue, double highValue) {
    MLData result = new BasicMLData(d.size());
    for(int i=0;i<d.size();i++) {
      if( d.getData(i)>=threshold ) {
        result.setData(i, highValue);
      } else {
        result.setData(i, lowValue);
      }
    }
    return result;
  }
View Full Code Here

    for (int i = 0; i < afs.length; i++) {
      afs[i] = af;
    }

    final double c = this.maxWeight / (1.0 - this.minWeight);
    final MLData input = new BasicMLData(cppn.getInputCount());

    // First create all of the non-bias links.
    for (final SubstrateLink link : substrate.getLinks()) {
      final SubstrateNode source = link.getSource();
      final SubstrateNode target = link.getTarget();

      int index = 0;
      for (final double d : source.getLocation()) {
        input.setData(index++, d);
      }
      for (final double d : target.getLocation()) {
        input.setData(index++, d);
      }
      final MLData output = cppn.compute(input);

      double weight = output.getData(0);
      if (Math.abs(weight) > this.minWeight) {
        weight = (Math.abs(weight) - this.minWeight) * c
            * Math.signum(weight);
        linkList.add(new NEATLink(source.getId(), target.getId(),
            weight));
      }
    }

    // now create biased links
    input.clear();
    final int d = substrate.getDimensions();
    final List<SubstrateNode> biasedNodes = substrate.getBiasedNodes();
    for (final SubstrateNode target : biasedNodes) {
      for (int i = 0; i < d; i++) {
        input.setData(d + i, target.getLocation()[i]);
      }

      final MLData output = cppn.compute(input);

      double biasWeight = output.getData(1);
View Full Code Here

    this.etFact = etFact;
  }

  @Override
  public MLData evaluate(ArrayList<MLData> outputs) {
    BasicMLData merged_outputs = new BasicMLData(classifier.getInputCount());
    int index = 0;
    for(MLData output:outputs)
      for(double val:output.getData()) {
        merged_outputs.add(index++,val);
      }
    return classifier.compute(merged_outputs);
  }
View Full Code Here

    return 1;
  }

  @Override
  public MLData compute(MLData input) {
    BasicMLData result = new BasicMLData(1);
   
    Matrix m1 = Matrix.createRowMatrix(input.getData());
    Matrix m2 = MatrixMath.subtract(m1, this.mu);
    Matrix m3 = MatrixMath.transpose(m2);
    Matrix m4 = MatrixMath.multiply(sigmaInverse, m3);
    Matrix m5 = MatrixMath.multiply(m4, m2);
   
    result.setData(0, m5.get(0, 0));
   
    /* double d1 = x.minus(mu).transpose().times
      (sigmaInverse).times(x.minus(mu)).get(0,0);
   
    double d2 = Math.exp(-0.5*d1) / normConst;
View Full Code Here

   
    for(int i=0;i<input.size();i++) { 
      sum[0] += this.weights[i+1] * Math.pow(input.getData(i),i+1);
    }
   
    return new BasicMLData(sum);
  }
View Full Code Here

    for (int i = 0; i < this.dimension; i++) {
      d[i] = ContinousDistribution.randomGenerator.nextGaussian();
    }

    final double[] d2 = MatrixMath.multiply(this.covarianceL, d);
    return new BasicMLDataPair(new BasicMLData(EngineArray.add(d2,
        this.mean)));
  }
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

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.