Package org.encog.ml

Examples of org.encog.ml.MLMethod


  private void embedNetwork(final EncogProgramNode node) {
    addBreak();

    final File methodFile = (File) node.getArgs().get(0).getValue();

    final MLMethod method = (MLMethod) EncogDirectoryPersistence
        .loadObject(methodFile);

    if (!(method instanceof MLFactory)) {
      throw new EncogError("Code generation not yet supported for: "
          + method.getClass().getName());
    }

    final MLFactory factoryMethod = (MLFactory) method;

    final String methodName = factoryMethod.getFactoryType();
View Full Code Here


        MLTrainFactory.PROPERTY_POPULATION_SIZE, false, 5000);
   
    MLTrain train = new MLMethodGeneticAlgorithm(new MethodFactory(){
      @Override
      public MLMethod factor() {
        final MLMethod result = (MLMethod) ObjectCloner.deepCopy(method);
        ((MLResettable)result).reset();
        return result;
      }}, score, populationSize);

    return train;
View Full Code Here

    final File resourceFile = getScript().resolveFilename(resourceID);

    final File outputFile = getAnalyst().getScript().resolveFilename(
        outputID);
   
    MLMethod m = (MLMethod) EncogDirectoryPersistence.loadObject(resourceFile);
   
    if( !(m instanceof MLRegression) ) {
      throw new AnalystError("The evaluate raw command can only be used with regression.");
    }
View Full Code Here

    final ScriptProperties prop = this.encogAnalyst.getScript().getProperties();
    final String resourceID = prop.getPropertyString(
        ScriptProperties.ML_CONFIG_MACHINE_LEARNING_FILE);
    final File resourceFile = this.encogAnalyst.getScript().resolveFilename(resourceID);

    final MLMethod method = (MLMethod) EncogDirectoryPersistence
        .loadObject(resourceFile);

    if (!(method instanceof MLMethod)) {
      throw new AnalystError(
          "The object to be trained must be an instance of MLMethod. "
              + method.getClass().getSimpleName());
    }

    return method;
  }
View Full Code Here

    double e = calculateError();
    Assert.assertTrue(e<targetError);
  }
 
  public double calculateError() {
    MLMethod method = obtainMethod();
    MLDataSet data = obtainTrainingSet();
    return ((MLError)method).calculateError(data);
  }
View Full Code Here

    // try rewrite
    this.rules.rewrite(g);

    // decode
    final MLMethod phenotype = getCODEC().decode(g);
    double score;

    // deal with invalid decode
    if (phenotype == null) {
      if (getBestComparator().shouldMinimize()) {
View Full Code Here

  /**
   * Perform the task.
   */
  @Override
  public void run() {
    MLMethod phenotype = this.owner.getCodec().decode(this.genome);
    if (phenotype != null) {
      double score;
      try {
        score = this.scoreFunction.calculateScore(phenotype);
      } catch(EARuntimeError e) {
View Full Code Here

   * @param k The number of folds total.
   * @param foldNum The current fold.
   * @param fold The current fold.
   */
  private void fitFold(int k, int foldNum, DataFold fold) {
    MLMethod method = this.createMethod();
    MLTrain train = this.createTrainer(method, fold.getTraining());

    if (train.getImplementationType() == TrainingImplementationType.Iterative) {
      SimpleEarlyStoppingStrategy earlyStop = new SimpleEarlyStoppingStrategy(
          fold.getValidation());
View Full Code Here

      fitFold(k, foldNumber, fold);
    }

    double sum = 0;
    double bestScore = Double.POSITIVE_INFINITY;
    MLMethod bestMethod = null;
    for (DataFold fold : cross.getFolds()) {
      sum += fold.getScore();
      if (fold.getScore() < bestScore) {
        bestScore = fold.getScore();
        bestMethod = fold.getMethod();
View Full Code Here

    if (this.methodType == null) {
      throw new EncogError(
          "Please call selectMethod first to choose what type of method you wish to use.");
    }
    MLMethodFactory methodFactory = new MLMethodFactory();
    MLMethod method = methodFactory.create(methodType, methodArgs, dataset
        .getNormHelper().calculateNormalizedInputCount(), this.config
        .determineOutputCount(dataset));
    return method;
  }
View Full Code Here

TOP

Related Classes of org.encog.ml.MLMethod

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.