// 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; }
/** * 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; }
/** * 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; } }