Exemplo n.º 1
0
  private boolean isCombinable(Itemset itemseti, Itemset itemsetj) {
    int i;
    Item itemi, itemj;
    Itemset itemset;

    itemi = itemseti.get(itemseti.size() - 1);
    itemj = itemsetj.get(itemseti.size() - 1);
    if (itemi.getVariable() >= itemj.getVariable()) return (false);

    return (true);
  }
Exemplo n.º 2
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);
  }
Exemplo n.º 3
0
  /**
   * Function to check if our itemset is Subitemset (can be contained) of a given itemset
   *
   * @param a Itemset to check if can contain ours
   * @return boolean true = our itemset is subitemset of a, false = it isn't.
   */
  public boolean isSubItemset(Itemset a) {
    int i, j;
    Item itemi, itemj;
    boolean stop;

    if (this.clas != a.getClas()) return (false);

    for (i = 0; i < this.itemset.size(); i++) {
      itemi = this.itemset.get(i);

      stop = false;
      for (j = 0; j < a.itemset.size() && !stop; j++) {
        itemj = a.itemset.get(j);
        if (itemi.isEqual(itemj)) stop = true;
        else if (itemj.getVariable() >= itemi.getVariable()) return (false);
      }

      if (!stop) return (false);
    }

    return (true);
  }
Exemplo n.º 4
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);
  }