Examples of EncogFileSection


Examples of org.encog.persist.EncogFileSection

   */
  @Override
  public final Object read(final InputStream is) {
    final SVM result = new SVM();
    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("SVM")
          && section.getSubSectionName().equals("PARAMS")) {
        final Map<String, String> params = section.parseParams();
        result.getProperties().putAll(params);
      }
      if (section.getSectionName().equals("SVM")
          && section.getSubSectionName().equals("SVM-PARAM")) {
        final Map<String, String> params = section.parseParams();
        result.setInputCount(EncogFileSection.parseInt(params,
            PersistConst.INPUT_COUNT));
        result.getParams().C = EncogFileSection.parseDouble(params,
            PersistSVM.PARAM_C);
        result.getParams().cache_size = EncogFileSection.parseDouble(
            params, PersistSVM.PARAM_CACHE_SIZE);
        result.getParams().coef0 = EncogFileSection.parseDouble(params,
            PersistSVM.PARAM_COEF0);
        result.getParams().degree = EncogFileSection.parseInt(params,
            PersistSVM.PARAM_DEGREE);
        result.getParams().eps = EncogFileSection.parseDouble(params,
            PersistSVM.PARAM_EPS);
        result.getParams().gamma = EncogFileSection.parseDouble(params,
            PersistSVM.PARAM_GAMMA);
        result.getParams().kernel_type = EncogFileSection.parseInt(
            params, PersistSVM.PARAM_KERNEL_TYPE);
        result.getParams().nr_weight = EncogFileSection.parseInt(
            params, PersistSVM.PARAM_NUM_WEIGHT);
        result.getParams().nu = EncogFileSection.parseDouble(params,
            PersistSVM.PARAM_NU);
        result.getParams().p = EncogFileSection.parseDouble(params,
            PersistSVM.PARAM_P);
        result.getParams().probability = EncogFileSection.parseInt(
            params, PersistSVM.PARAM_PROBABILITY);
        result.getParams().shrinking = EncogFileSection.parseInt(
            params, PersistSVM.PARAM_SHRINKING);
        result.getParams().svm_type = EncogFileSection.parseInt(params,
            PersistSVM.PARAM_SVM_TYPE);
        result.getParams().weight = EncogFileSection.parseDoubleArray(
            params, PersistSVM.PARAM_WEIGHT);
        result.getParams().weight_label = EncogFileSection
            .parseIntArray(params, PersistSVM.PARAM_WEIGHT_LABEL);
      } else if (section.getSectionName().equals("SVM")
          && section.getSubSectionName().equals("SVM-MODEL")) {
        try {
          final StringReader rdr = new StringReader(
              section.getLinesAsString());
          final BufferedReader br = new BufferedReader(rdr);
          final svm_model model = svm.svm_load_model(br);
          result.setModel(model);
          br.close();
          rdr.close();
View Full Code Here

Examples of org.encog.persist.EncogFileSection

   */
  @Override
  public final Object read(final InputStream is) {
    final SOM result = new SOM();
    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("SOM")
          && section.getSubSectionName().equals("PARAMS")) {
        final Map<String, String> params = section.parseParams();
        result.getProperties().putAll(params);
      }
      if (section.getSectionName().equals("SOM")
          && section.getSubSectionName().equals("NETWORK")) {
        final Map<String, String> params = section.parseParams();
        result.setWeights(EncogFileSection.parseMatrix(params,
            PersistConst.WEIGHTS));
        result.setOutputNeuronCount(EncogFileSection.parseInt(params,
            PersistConst.OUTPUT_COUNT));
        result.setInputCount(EncogFileSection.parseInt(params,
View Full Code Here

Examples of org.encog.persist.EncogFileSection

   */
  @Override
  public final Object read(final InputStream is) {

    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;
    final BasicMLDataSet samples = new BasicMLDataSet();
    Map<String, String> networkParams = null;
    PNNKernelType kernel = null;
    PNNOutputMode outmodel = null;
    int inputCount = 0;
    int outputCount = 0;
    double error = 0;
    double[] sigma = null;

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("PNN")
          && section.getSubSectionName().equals("PARAMS")) {
        networkParams = section.parseParams();
      }
      if (section.getSectionName().equals("PNN")
          && section.getSubSectionName().equals("NETWORK")) {
        final Map<String, String> params = section.parseParams();
        inputCount = EncogFileSection.parseInt(params,
            PersistConst.INPUT_COUNT);
        outputCount = EncogFileSection.parseInt(params,
            PersistConst.OUTPUT_COUNT);
        kernel = PersistBasicPNN.stringToKernel(params
            .get(PersistConst.KERNEL));
        outmodel = PersistBasicPNN.stringToOutputMode(params
            .get(PersistBasicPNN.PROPERTY_outputMode));
        error = EncogFileSection
            .parseDouble(params, PersistConst.ERROR);
        sigma = EncogFileSection.parseDoubleArray(params,
            PersistConst.SIGMA);
      }
      if (section.getSectionName().equals("PNN")
          && section.getSubSectionName().equals("SAMPLES")) {
        for (final String line : section.getLines()) {
          final List<String> cols = EncogFileSection
              .splitColumns(line);
          int index = 0;
          final MLData inputData = new BasicMLData(inputCount);
          for (int i = 0; i < inputCount; i++) {
View Full Code Here

Examples of org.encog.persist.EncogFileSection

      File file = new File(home, EncogWorkBench.CONFIG_FILENAME);
      InputStream is = new FileInputStream(file);
      EncogReadHelper in = new EncogReadHelper(is);
     
      // read the config file
      EncogFileSection section;
     
      while( (section = in.readNextSection()) != null ) {
        if( section.getSectionName().equals("ENCOG") && section.getSubSectionName().equals("TRAINING") ) {
          Map<String,String> params = section.parseParams();
          this.defaultError = EncogFileSection.parseDouble(params, EncogWorkBenchConfig.PROPERTY_DEFAULT_ERROR);
          this.threadCount = EncogFileSection.parseInt(params, EncogWorkBenchConfig.PROPERTY_THREAD_COUNT);
          this.useOpenCL = EncogFileSection.parseInt(params, EncogWorkBenchConfig.PROPERTY_THREAD_COUNT)>0;
          this.errorCalculation = EncogFileSection.parseInt(params, EncogWorkBenchConfig.PROPERTY_ERROR_CALC);
        }
View Full Code Here

Examples of org.encog.persist.EncogFileSection

   */
  public final void load(final InputStream stream) {
    EncogReadHelper reader = null;

    try {
      EncogFileSection section = null;
      reader = new EncogReadHelper(stream);

      while ((section = reader.readNextSection()) != null) {
        processSubSection(section);
      }
View Full Code Here

Examples of org.encog.persist.EncogFileSection

   */
  @Override
  public Object read(final InputStream is) {
    final BAM result = new BAM();
    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("BAM")
          && section.getSubSectionName().equals("PARAMS")) {
        final Map<String, String> params = section.parseParams();
        result.getProperties().putAll(params);
      }
      if (section.getSectionName().equals("BAM")
          && section.getSubSectionName().equals("NETWORK")) {
        final Map<String, String> params = section.parseParams();

        result.setF1Count(EncogFileSection.parseInt(params,
            PersistConst.PROPERTY_F1_COUNT));
        result.setF2Count(EncogFileSection.parseInt(params,
            PersistConst.PROPERTY_F2_COUNT));
View Full Code Here

Examples of org.encog.persist.EncogFileSection

   */
  @Override
  public Object read(final InputStream is) {
    Map<String, String> networkParams = null;
    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;
    int inputCount = 0;
    int instarCount = 0;
    int outputCount = 0;
    int winnerCount = 0;
    Matrix m1 = null;
    Matrix m2 = null;

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("CPN")
          && section.getSubSectionName().equals("PARAMS")) {
        networkParams = section.parseParams();
      }
      if (section.getSectionName().equals("CPN")
          && section.getSubSectionName().equals("NETWORK")) {
        final Map<String, String> params = section.parseParams();

        inputCount = EncogFileSection.parseInt(params,
            PersistConst.INPUT_COUNT);
        instarCount = EncogFileSection.parseInt(params,
            PersistConst.INSTAR);
View Full Code Here

Examples of org.encog.persist.EncogFileSection

   */
  @Override
  public final Object read(final InputStream is) {
    final BayesianNetwork result = new BayesianNetwork();
    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;
    String queryType = "";
    String queryStr = "";
    String contentsStr = "";

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("BAYES-NETWORK")
          && section.getSubSectionName().equals("BAYES-PARAM")) {
        final Map<String, String> params = section.parseParams();
        queryType = params.get("queryType");
        queryStr = params.get("query");
        contentsStr = params.get("contents");
      }
      if (section.getSectionName().equals("BAYES-NETWORK")
          && section.getSubSectionName().equals("BAYES-TABLE")) {

        result.setContents(contentsStr);
       
        // first, define relationships (1st pass)
        for (String line : section.getLines()) {
          result.defineRelationship(line);
        }

        result.finalizeStructure();

        // now define the probabilities (2nd pass)
        for (String line : section.getLines()) {
          result.defineProbability(line);
        }
      }
      if (section.getSectionName().equals("BAYES-NETWORK")
          && section.getSubSectionName().equals("BAYES-PROPERTIES")) {
        final Map<String, String> params = section.parseParams();
        result.getProperties().putAll(params);
      }
    }

    // define query, if it exists
View Full Code Here

Examples of org.encog.persist.EncogFileSection

    final EncogProgramContext context = new EncogProgramContext();

    final PrgPopulation result = new PrgPopulation(context, 0);

    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;

    int count = 0;
    Species lastSpecies = null;
    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("BASIC")
          && section.getSubSectionName().equals("PARAMS")) {
        final Map<String, String> params = section.parseParams();
        result.getProperties().putAll(params);
      } else if (section.getSectionName().equals("BASIC")
          && section.getSubSectionName().equals("EPL-POPULATION")) {
        for (final String line : section.getLines()) {
          final List<String> cols = EncogFileSection
              .splitColumns(line);

          if (cols.get(0).equalsIgnoreCase("s")) {
            lastSpecies = new BasicSpecies();
            lastSpecies.setAge(Integer.parseInt(cols.get(1)));
            lastSpecies.setBestScore(CSVFormat.EG_FORMAT.parse(cols
                .get(2)));
            lastSpecies.setPopulation(result);
            lastSpecies.setGensNoImprovement(Integer.parseInt(cols
                .get(3)));
            result.getSpecies().add(lastSpecies);
          } else if (cols.get(0).equalsIgnoreCase("p")) {
            double score = 0;
            double adjustedScore = 0;

            if (cols.get(1).equalsIgnoreCase("nan")
                || cols.get(2).equalsIgnoreCase("nan")) {
              score = Double.NaN;
              adjustedScore = Double.NaN;
            } else {
              score = CSVFormat.EG_FORMAT.parse(cols.get(1));
              adjustedScore = CSVFormat.EG_FORMAT.parse(cols
                  .get(2));
            }

            final String code = cols.get(3);
            final EncogProgram prg = new EncogProgram(context);
            prg.compileEPL(code);
            prg.setScore(score);
            prg.setSpecies(lastSpecies);
            prg.setAdjustedScore(adjustedScore);
            if (lastSpecies == null) {
              throw new EncogError(
                  "Have not defined a species yet");
            } else {
              lastSpecies.add(prg);
            }
            count++;
          }
        }
      } else if (section.getSectionName().equals("BASIC")
          && section.getSubSectionName().equals("EPL-OPCODES")) {
        for (final String line : section.getLines()) {
          final List<String> cols = EncogFileSection
              .splitColumns(line);
          final String name = cols.get(0);
          final int args = Integer.parseInt(cols.get(1));
          result.getContext().getFunctions().addExtension(name, args);
        }
      } else if (section.getSectionName().equals("BASIC")
          && section.getSubSectionName().equals("EPL-SYMBOLIC")) {
        boolean first = true;
        for (final String line : section.getLines()) {
          if (!first) {
            final List<String> cols = EncogFileSection
                .splitColumns(line);
            final String name = cols.get(0);
            final String t = cols.get(1);
View Full Code Here

Examples of org.encog.persist.EncogFileSection

   */
  @Override
  public Object read(final InputStream is) {
    final ART1 result = new ART1();
    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("ART1")
          && section.getSubSectionName().equals("PARAMS")) {
        final Map<String, String> params = section.parseParams();
        result.getProperties().putAll(params);
      }
      if (section.getSectionName().equals("ART1")
          && section.getSubSectionName().equals("NETWORK")) {
        final Map<String, String> params = section.parseParams();

        result.setA1(EncogFileSection.parseDouble(params,
            ART.PROPERTY_A1));
        result.setB1(EncogFileSection.parseDouble(params,
            ART.PROPERTY_B1));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.