Exemplo n.º 1
0
 /**
  * Get a shallow copy of this rule
  *
  * @return the copy
  */
 public Object copy() {
   RipperRule copy = new RipperRule();
   copy.setConsequent(getConsequent());
   copy.m_Antds = (FastVector) this.m_Antds.copyElements();
   copy.aprioriDistribution = this.aprioriDistribution.clone();
   return copy;
 }
Exemplo n.º 2
0
  public void calculateConfidences(Instances data) throws Exception {
    RipperRule tempRule = (RipperRule) this.copy();

    while (tempRule.hasAntds()) {
      double acc = 0;
      double cov = 0;
      for (int i = 0; i < data.numInstances(); i++) {
        double membershipValue = tempRule.coverageDegree(data.instance(i));
        cov += membershipValue;
        if (m_Consequent == data.instance(i).classValue()) {
          acc += membershipValue;
        }
      }

      // m-estimate
      double m = 2.0;
      ((Antd) this.m_Antds.elementAt((int) tempRule.size() - 1)).m_confidence =
          (acc + m * (aprioriDistribution[(int) m_Consequent] / Utils.sum(aprioriDistribution)))
              / (cov + m);
      tempRule.m_Antds.removeElementAt(tempRule.m_Antds.size() - 1);
    }
  }