Esempio n. 1
0
  /**
   * Detects which leaf a itemset falls into
   *
   * @param itemset the itemset
   * @return the leaf no.
   */
  public final int leafNum(Itemset itemset) {

    int lmNum = 0;

    if (type == false) {
      lmNum = lm;
    } else {
      if (itemset.getValue(splitAttr) <= splitValue) {
        lmNum = leftNode.leafNum(itemset);
      } else {
        lmNum = rightNode.leafNum(itemset);
      }
    }

    return lmNum;
  }
Esempio n. 2
0
  /**
   * Predicts the class value of an itemset by the tree
   *
   * @param itemset the itemset
   * @param smooth =true, uses the smoothed model; otherwise uses the unsmoothed
   * @inst itemsets
   * @return the predicted value
   */
  public final double predict(Itemset itemset, boolean smooth) {

    double y = 0.0;

    if (type == false) { // LEAF
      if (smooth == true) {
        y = smoothed.predict(itemset);
      } else {
        if (valueNode == true) {
          y = unsmoothed.coeffs[0];
        } else {
          y = unsmoothed.predict(itemset);
        }
      }
    } else { // NODE
      if (itemset.getValue(splitAttr) <= splitValue) {
        y = leftNode.predict(itemset, smooth);
      } else {
        y = rightNode.predict(itemset, smooth);
      }
    }

    return y;
  }