Package org.encog.ml.bayesian

Examples of org.encog.ml.bayesian.BayesianError


   */
  public int resolveValue(BayesianEvent actualEvent) {
    int result = 0;
   
    if( this.value==null ) {
      throw new BayesianError("Value is undefined for " + this.label + " should express a value with +, - or =.");
    }
   
    for(BayesianChoice choice: actualEvent.getChoices()) {
      if( this.value.equals(choice.getLabel())) {
        return result;
      }
      result++;
    }
   
    // resolve true/false if not found, probably came from +/- notation
    if( this.value.equalsIgnoreCase("true")) {
      return 0;
    } else if( this.value.equalsIgnoreCase("false")) {
      return 1;
    }
   
    // try to resolve numeric index
    try {
      int i = Integer.parseInt(this.value);
      if( i<actualEvent.getChoices().size() ) {
        return i;
      }
    } catch(NumberFormatException ex) {
      // well, we tried
    }
   
    // error out if nothing found
    throw new BayesianError("Can'f find choice " + this.value + " in the event " + this.label );
  }
View Full Code Here


      search = new SearchK2();
    } else if( searchStr.equalsIgnoreCase("none")) {
      search = new SearchNone();
    }
    else {
      throw new BayesianError("Invalid search type: " + searchStr);
    }
   
    if( estimatorStr.equalsIgnoreCase("simple")) {
      estimator = new SimpleEstimator();
    } else if( estimatorStr.equalsIgnoreCase("none")) {
      estimator = new EstimatorNone();
    }
    else {
      throw new BayesianError("Invalid estimator type: " + estimatorStr);
    }
   
    if( initStr.equalsIgnoreCase("simple")) {
      init = BayesianInit.InitEmpty;
    } else if( initStr.equalsIgnoreCase("naive")) {
      init = BayesianInit.InitNaiveBayes;
    } else if( initStr.equalsIgnoreCase("none")) {
      init = BayesianInit.InitNoChange;
    }
    else {
      throw new BayesianError("Invalid init type: " + initStr);
    }
   
    return new TrainBayesian((BayesianNetwork) method, training, maxParents, init, search, estimator);
  }
View Full Code Here

          return line.getProbability();
        }
      }
    }

    throw new BayesianError("Could not determine the probability for "
        + state.toString());
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public void setEventValue(BayesianEvent event, int d) {
    if( getEventType(event)==EventType.Hidden) {
      throw new BayesianError("You may only set the value of an evidence or outcome event.");
    }
   
    getEventState(event).setCompareValue(d);
    getEventState(event).setValue(d);
  }
View Full Code Here

    this.compareValue = compareValue;
  }

  public boolean isSatisfied() {
    if (eventType == EventType.Hidden) {
      throw new BayesianError(
          "Satisfy can't be called on a hidden event.");
    }
    return Math.abs(this.compareValue - this.value) < Encog.DEFAULT_DOUBLE_EQUAL;
  }
View Full Code Here

        for (EventState state : getEvents().values()) {
          randomizeEvents(state);
        }
        uncalculated = countUnCalculated();
        if (uncalculated == lastUncalculated) {
          throw new BayesianError(
              "Unable to calculate all nodes in the graph.");
        }
        lastUncalculated = uncalculated;
      } while (uncalculated > 0);
View Full Code Here

TOP

Related Classes of org.encog.ml.bayesian.BayesianError

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.