Esempio n. 1
0
  /**
   * This function generates a classifier from the CompSet of the generated fuzzy rules
   *
   * @return Classifier obtained
   */
  public RuleBase classifier() {
    int i, j;
    boolean stop;
    Rule rule;
    RuleBase bestRuleBase;

    for (i = 0; i < this.ruleBase.size(); i++) {
      rule = this.ruleBase.get(i);
      rule.orderDF();
    }

    this.fitness = this.train.size();
    bestRuleBase = this.clone();
    System.out.println("Fitness Inicial: " + this.fitness);

    if (this.ruleBase.size() > 1) {
      do {
        this.calculateRightNWrongN();
        this.removeRules();

        this.rateError();
        System.out.println("Fitness: " + this.fitness + " NRules: " + this.ruleBase.size());

        stop = true;
        if (this.fitness <= bestRuleBase.fitness) {
          bestRuleBase = this.clone();
          if (this.ruleBase.size() > 1 && this.fitness > 0) stop = false;
        }
      } while (!stop);
    }

    bestRuleBase.evalua();

    return (bestRuleBase);
  }