Пример #1
0
  private double degree(int[] example) {
    double degree;
    Item item;

    degree = 1.0;
    for (int i = 0; i < itemset.size() && degree > 0.0; i++) {
      item = itemset.get(i);
      if (item.getValue() != example[item.getVariable()]) degree = 0.0;
    }
    return (degree);
  }
Пример #2
0
  /**
   * It adds a rule to the rule base
   *
   * @param itemset itemset to be added
   * @param time Time of the rule
   */
  public void add(Itemset itemset, long time) {
    int i;
    Item item;

    int[] antecedent = new int[n_variables];
    for (i = 0; i < n_variables; i++) antecedent[i] = -1; // Don't care

    for (i = 0; i < itemset.size(); i++) {
      item = itemset.get(i);
      antecedent[item.getVariable()] = item.getValue();
    }

    Rule r = new Rule(this.dataBase);
    r.asignaAntecedente(antecedent);
    r.setConsequent(itemset.getClas());
    r.setConfidence(itemset.getSupportClass() / itemset.getSupport());
    r.setSupport(itemset.getSupportClass());
    r.setTime(time);
    this.ruleBase.add(r);
  }