@Override
    public void incrementalRedraw() {
      if (layer == null) {
        makeLayerElement();
        addCSSClasses();
      }

      // TODO make the number of digits configurable
      final String label = (epsilon > 0.0) ? FormatUtil.NF4.format(epsilon) : "";
      // compute absolute y-value of bar
      final double yAct = getYFromEpsilon(epsilon);

      if (elemText == null) {
        elemText = svgp.svgText(StyleLibrary.SCALE * 1.05, yAct, label);
        SVGUtil.setAtt(elemText, SVGConstants.SVG_CLASS_ATTRIBUTE, CSS_EPSILON);
        layer.appendChild(elemText);
      } else {
        elemText.setTextContent(label);
        SVGUtil.setAtt(elemText, SVGConstants.SVG_Y_ATTRIBUTE, yAct);
      }

      // line and handle
      if (elementLine == null) {
        elementLine = svgp.svgLine(0, yAct, StyleLibrary.SCALE * 1.04, yAct);
        SVGUtil.addCSSClass(elementLine, CSS_LINE);
        layer.appendChild(elementLine);
      } else {
        SVGUtil.setAtt(elementLine, SVG12Constants.SVG_Y1_ATTRIBUTE, yAct);
        SVGUtil.setAtt(elementLine, SVG12Constants.SVG_Y2_ATTRIBUTE, yAct);
      }
      if (elementPoint == null) {
        elementPoint = svgp.svgCircle(StyleLibrary.SCALE * 1.04, yAct, StyleLibrary.SCALE * 0.004);
        SVGUtil.addCSSClass(elementPoint, CSS_LINE);
        layer.appendChild(elementPoint);
      } else {
        SVGUtil.setAtt(elementPoint, SVG12Constants.SVG_CY_ATTRIBUTE, yAct);
      }

      if (eventarea == null) {
        eventarea =
            new DragableArea(
                svgp,
                StyleLibrary.SCALE,
                -StyleLibrary.SCALE * 0.01, //
                StyleLibrary.SCALE * 0.1,
                plotheight + StyleLibrary.SCALE * 0.02,
                this);
        layer.appendChild(eventarea.getElement());
      }
    }
Esempio n. 2
0
    /**
     * Constructor.
     *
     * @param contmat score result
     */
    public ScoreResult(ClusterContingencyTable contmat) {
      super("Cluster-Evalation", "cluster-evaluation");
      this.contmat = contmat;

      PairCounting paircount = contmat.getPaircount();
      MeasurementGroup g = newGroup("Pair counting measures");
      g.addMeasure("Jaccard", paircount.jaccard(), 0, 1, false);
      g.addMeasure("F1-Measure", paircount.f1Measure(), 0, 1, false);
      g.addMeasure("Precision", paircount.precision(), 0, 1, false);
      g.addMeasure("Recall", paircount.recall(), 0, 1, false);
      g.addMeasure("Rand", paircount.randIndex(), 0, 1, false);
      g.addMeasure("ARI", paircount.adjustedRandIndex(), 0, 1, false);
      g.addMeasure("FowlkesMallows", paircount.fowlkesMallows(), 0, 1, false);

      Entropy entropy = contmat.getEntropy();
      g = newGroup("Entropy based measures");
      g.addMeasure("NMI Joint", entropy.entropyNMIJoint(), 0, 1, false);
      g.addMeasure("NMI Sqrt", entropy.entropyNMISqrt(), 0, 1, false);

      BCubed bcubed = contmat.getBCubed();
      g = newGroup("BCubed-based measures");
      g.addMeasure("F1-Measure", bcubed.f1Measure(), 0, 1, false);
      g.addMeasure("Recall", bcubed.recall(), 0, 1, false);
      g.addMeasure("Precision", bcubed.precision(), 0, 1, false);

      SetMatchingPurity setm = contmat.getSetMatching();
      g = newGroup("Set-Matching-based measures");
      g.addMeasure("F1-Measure", setm.f1Measure(), 0, 1, false);
      g.addMeasure("Purity", setm.purity(), 0, 1, false);
      g.addMeasure("Inverse Purity", setm.inversePurity(), 0, 1, false);

      EditDistance edit = contmat.getEdit();
      g = newGroup("Editing-distance measures");
      g.addMeasure("F1-Measure", edit.f1Measure(), 0, 1, false);
      g.addMeasure("Precision", edit.editDistanceFirst(), 0, 1, false);
      g.addMeasure("Recall", edit.editDistanceSecond(), 0, 1, false);

      MeanVariance gini = contmat.averageSymmetricGini();
      g = newGroup("Gini measures");
      g.addMeasure(
          "Mean +-" + FormatUtil.NF4.format(gini.getCount() > 1. ? gini.getSampleStddev() : 0.),
          gini.getMean(),
          0,
          1,
          false);
    }