Esempio n. 1
0
 /**
  * Calculates the difference
  *
  * @return difference
  */
 public double prototypeDifference(CombStat stat) {
   double sumdiff = 0;
   double weight;
   // Numeric atts: abs difference
   for (int i = 0; i < m_RegStat.getNbNumericAttributes(); i++) {
     weight = m_StatManager.getClusteringWeights().getWeight(m_RegStat.getAttribute(i));
     sumdiff += Math.abs(prototypeNum(i) - stat.prototypeNum(i)) * weight;
     // System.err.println("sumdiff: " + Math.abs(prototypeNum(i) - stat.prototypeNum(i)) *
     // weight);
   }
   // Nominal atts: Manhattan distance
   for (int i = 0; i < m_ClassStat.getNbNominalAttributes(); i++) {
     weight = m_StatManager.getClusteringWeights().getWeight(m_ClassStat.getAttribute(i));
     double sum = 0;
     double[] proto1 = prototypeNom(i);
     double[] proto2 = stat.prototypeNom(i);
     for (int j = 0; j < proto1.length; j++) {
       sum += Math.abs(proto1[j] - proto2[j]);
     }
     sumdiff += sum * weight;
     // System.err.println("sumdiff: " + (sum * weight));
   }
   // System.err.println("sumdiff-total: " + sumdiff);
   return sumdiff != 0 ? sumdiff : 0.0;
 }
Esempio n. 2
0
 // TODO: Move to ClassificationStat
 public double meanEntropy() {
   double sent = 0;
   int nbNominal = m_ClassStat.getNbNominalAttributes();
   for (int i = 0; i < nbNominal; i++) {
     sent += entropy(i);
   }
   return sent / nbNominal;
 }
Esempio n. 3
0
 public double getSVarSDiff(ClusAttributeWeights scale, ClusStatistic other) {
   int nbTargetNom = m_ClassStat.getNbNominalAttributes();
   int nbTargetNum = m_RegStat.getNbNumericAttributes();
   ClassificationStat ocls = ((CombStat) other).getClassificationStat();
   RegressionStat oreg = ((CombStat) other).getRegressionStat();
   return (m_ClassStat.getSVarSDiff(scale, ocls) * nbTargetNom
           + m_RegStat.getSVarSDiff(scale, oreg) * nbTargetNum)
       / (nbTargetNom + nbTargetNum);
 }
Esempio n. 4
0
 // TODO: Move to ClassificationStat
 public double meanDistNom(int use) {
   double sumdist = 0;
   double weight = 0;
   for (int i = 0; i < m_ClassStat.getNbNominalAttributes(); i++) {
     if (use == IN_HEURISTIC) {
       weight = m_StatManager.getClusteringWeights().getWeight(m_ClassStat.getAttribute(i));
     } else { // use == IN_OUTPUT
       weight = m_StatManager.getDispersionWeights().getWeight(m_ClassStat.getAttribute(i));
     }
     sumdist += meanDistNomOne(i) * weight;
   }
   return sumdist;
 }
Esempio n. 5
0
 /**
  * Checks weather values of a target attribute are significantly different
  *
  * @return
  */
 public boolean targetSignDifferent() {
   boolean res = false;
   int att = -1;
   String att_name;
   String att_name2;
   ClusStatistic targetStat = m_StatManager.getStatistic(ClusAttrType.ATTR_USE_TARGET);
   if (targetStat instanceof ClassificationStat) {
     for (int i = 0; i < targetStat.getNbNominalAttributes(); i++) {
       att_name = ((ClassificationStat) targetStat).getAttribute(i).getName();
       for (int j = 0; j < m_ClassStat.getNbNominalAttributes(); j++) {
         att_name2 = m_ClassStat.getAttribute(j).getName();
         if (att_name.equals(att_name2)) {
           att = j;
           break;
         }
       }
       if (SignDifferentNom(att)) {
         res = true;
         break; // TODO: If one target att significant, the whole rule significant!?
       }
     }
     // System.out.println("Target sign. testing: " + res);
     return res;
   } else if (targetStat instanceof RegressionStat) {
     for (int i = 0; i < targetStat.getNbNumericAttributes(); i++) {
       att_name = ((RegressionStat) targetStat).getAttribute(i).getName();
       for (int j = 0; j < m_RegStat.getNbNumericAttributes(); j++) {
         att_name2 = m_RegStat.getAttribute(j).getName();
         if (att_name.equals(att_name2)) {
           att = j;
           break;
         }
       }
       try {
         if (SignDifferentNum(att)) {
           res = true;
           break; // TODO: If one target att significant, the whole rule significant!?
         }
       } catch (IllegalArgumentException e) {
         e.printStackTrace();
       } catch (MathException e) {
         e.printStackTrace();
       }
     }
     return res;
   } else {
     // TODO: Classification and regression
     return true;
   }
 }
Esempio n. 6
0
 public int getNbNominalAttributes() {
   return m_ClassStat.getNbNominalAttributes();
 }
Esempio n. 7
0
 // TODO: Not sure this makes sense in CombStat - Check!
 public double getSVarS(ClusAttributeWeights scale) {
   int nbTargetNom = m_ClassStat.getNbNominalAttributes();
   int nbTargetNum = m_RegStat.getNbNumericAttributes();
   return (m_ClassStat.getSVarS(scale) * nbTargetNom + m_RegStat.getSVarS(scale) * nbTargetNum)
       / (nbTargetNom + nbTargetNum);
 }