@Override
 public String toString() {
   updateDistributionProperties();
   return ("Normal distribution --> mean: "
       + Tools.formatNumber(mean)
       + ", standard deviation: "
       + Tools.formatNumber(standardDeviation));
 }
Пример #2
0
 public String toString() {
   return "ANOVA result (f="
       + Tools.formatNumber(fValue)
       + ", prob="
       + Tools.formatNumber(prob)
       + ", alpha="
       + Tools.formatNumber(alpha)
       + ")";
 }
 public Object getValueAt(int row, int col) {
   if (col == 0) {
     return matrix.getAnovaAttributeNames().get(row);
   } else {
     return Tools.formatNumber(matrix.getProbabilities()[row][col - 1]);
   }
 }
Пример #4
0
 @Override
 public String toResultString() {
   StringBuilder result =
       new StringBuilder(
           Tools.getLineSeparator() + "Principal Components:" + Tools.getLineSeparator());
   if (manualNumber) {
     result.append("Number of Components: " + numberOfComponents + Tools.getLineSeparator());
   } else {
     result.append("Proportion Threshold: " + proportionThreshold + Tools.getLineSeparator());
   }
   for (int i = 0; i < vMatrix.getColumnDimension(); i++) {
     result.append("PC " + (i + 1) + ": ");
     for (int j = 0; j < attributeNames.length; j++) {
       double value = vMatrix.get(i, j);
       if (value > 0) {
         result.append(" + ");
       } else {
         result.append(" - ");
       }
       result.append(Tools.formatNumber(Math.abs(value)) + " * " + attributeNames[j]);
     }
     result.append(Tools.getLineSeparator());
   }
   return result.toString();
 }
 @Override
 public List<String> getModelNames() {
   List<String> names = new LinkedList<String>();
   for (int i = 0; i < this.getNumberOfModels(); i++) {
     names.add("Model " + (i + 1) + " [w = " + Tools.formatNumber(getWeightForModel(i)) + "]");
   }
   return names;
 }
 @Override
 public String toString() {
   String results = new String();
   for (int i = 0; i < names.size(); i++) {
     results +=
         names.get(i).toString() + ": " + Tools.formatNumber(values.get(i).doubleValue()) + "\n";
   }
   return results;
   // return name+" "+ Tools.formatNumber(value);
 }
  @Override
  public Component getVisualizationComponent(Object renderable, IOContainer ioContainer) {
    TTestSignificanceTestResult result = (TTestSignificanceTestResult) renderable;

    PerformanceVector[] allVectors = result.getAllVectors();
    StringBuffer buffer = new StringBuffer();
    Color bgColor = SwingTools.LIGHTEST_YELLOW;
    String bgColorString =
        Integer.toHexString(bgColor.getRed())
            + Integer.toHexString(bgColor.getGreen())
            + Integer.toHexString(bgColor.getBlue());

    buffer.append("<table bgcolor=\"" + bgColorString + "\" border=\"1\">");
    buffer.append("<tr><td></td>");
    for (int i = 0; i < result.getAllVectors().length; i++) {
      buffer.append(
          "<td>"
              + Tools.formatNumber(allVectors[i].getMainCriterion().getAverage())
              + " +/- "
              + Tools.formatNumber(Math.sqrt(allVectors[i].getMainCriterion().getVariance()))
              + "</td>");
    }
    buffer.append("</tr>");
    for (int i = 0; i < allVectors.length; i++) {
      buffer.append(
          "<tr><td>"
              + Tools.formatNumber(allVectors[i].getMainCriterion().getAverage())
              + " +/- "
              + Tools.formatNumber(Math.sqrt(allVectors[i].getMainCriterion().getVariance()))
              + "</td>");
      for (int j = 0; j < allVectors.length; j++) {
        buffer.append("<td>");
        if (!Double.isNaN(result.getProbMatrix()[i][j])) {
          double prob = result.getProbMatrix()[i][j];
          if (prob < result.getAlpha()) {
            buffer.append("<b>");
          }
          buffer.append(Tools.formatNumber(prob));
          if (prob < result.getAlpha()) {
            buffer.append("</b>");
          }
        }
        buffer.append("</td>");
      }
      buffer.append("</tr>");
    }
    buffer.append("</table>");
    buffer.append(
        "<br>Probabilities for random values with the same result.<br>Bold values are smaller than alpha="
            + Tools.formatNumber(result.getAlpha())
            + " which indicates a probably significant difference between the actual mean values!");

    JEditorPane textPane =
        new ExtendedHTMLJEditorPane(
            "text/html", "<html><h1>" + getName() + "</h1>" + buffer.toString() + "</html>");
    textPane.setBackground((new JLabel()).getBackground());
    textPane.setBorder(javax.swing.BorderFactory.createEmptyBorder(11, 11, 11, 11));
    textPane.setEditable(false);
    return new ExtendedJScrollPane(textPane);
  }
Пример #8
0
  public static int fillDataTable(
      SimpleDataTable dataTable,
      Map<String, double[]> lastPopulation,
      Population pop,
      boolean drawDominated) {
    lastPopulation.clear();
    dataTable.clear();
    int numberOfCriteria = 0;
    for (int i = 0; i < pop.getNumberOfIndividuals(); i++) {
      boolean dominated = false;
      if (!drawDominated) {
        for (int j = 0; j < pop.getNumberOfIndividuals(); j++) {
          if (i == j) continue;
          if (NonDominatedSortingSelection.isDominated(pop.get(i), pop.get(j))) {
            dominated = true;
            break;
          }
        }
      }

      if (drawDominated || (!dominated)) {
        StringBuffer id = new StringBuffer(i + " (");
        PerformanceVector current = pop.get(i).getPerformance();
        numberOfCriteria = Math.max(numberOfCriteria, current.getSize());
        double[] data = new double[current.getSize()];
        for (int d = 0; d < data.length; d++) {
          data[d] = current.getCriterion(d).getFitness();
          if (d != 0) id.append(", ");
          id.append(Tools.formatNumber(data[d]));
        }
        id.append(")");
        dataTable.add(new SimpleDataTableRow(data, id.toString()));
        double[] weights = pop.get(i).getWeights();
        double[] clone = new double[weights.length];
        System.arraycopy(weights, 0, clone, 0, weights.length);
        lastPopulation.put(id.toString(), clone);
      }
    }
    return numberOfCriteria;
  }
 @Override
 public String toString() {
   StringBuffer distributionDescription = new StringBuffer();
   boolean first = true;
   for (int i = 0; i < valueNames.length; i++) {
     if (!first) {
       distributionDescription.append("\t");
     }
     distributionDescription.append(valueNames[i]);
     first = false;
   }
   first = true;
   distributionDescription.append(Tools.getLineSeparator());
   for (int i = 0; i < valueNames.length; i++) {
     if (!first) {
       distributionDescription.append("\t");
     }
     distributionDescription.append(Tools.formatNumber(probabilities[i]));
     first = false;
   }
   return distributionDescription.toString();
 }
Пример #10
0
  public ANOVAMatrixViewer(ANOVAMatrix matrix) {
    super(new BorderLayout());

    JPanel infoPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));

    // info string
    JTextPane infoText = new JTextPane();
    infoText.setEditable(false);
    infoText.setBackground(infoPanel.getBackground());
    infoText.setFont(infoText.getFont().deriveFont(Font.BOLD));
    infoText.setText(
        "A dark background indicates that the probability for non-difference between the groups is less than "
            + Tools.formatNumber(matrix.getSignificanceLevel()));
    infoPanel.add(infoText);
    infoPanel.setBorder(BorderFactory.createEtchedBorder());
    add(infoPanel, BorderLayout.NORTH);

    // table
    ANOVAMatrixViewerTable table = new ANOVAMatrixViewerTable(matrix);
    table.setBorder(BorderFactory.createEtchedBorder());
    add(new ExtendedJScrollPane(table), BorderLayout.CENTER);
  }
Пример #11
0
 @Override
 public String toResultString() {
   StringBuilder result =
       new StringBuilder(
           Tools.getLineSeparator() + "Principal Components:" + Tools.getLineSeparator());
   if (manualNumber) {
     result.append("Number of Components: " + numberOfComponents + Tools.getLineSeparator());
   } else {
     result.append("Variance Threshold: " + varianceThreshold + Tools.getLineSeparator());
   }
   for (int i = 0; i < eigenVectors.size(); i++) {
     result.append("PC " + (i + 1) + ": ");
     for (int j = 0; j < attributeNames.length; j++) {
       double value = eigenVectors.get(i).getEigenvector()[j];
       if (value > 0) result.append(" + ");
       else result.append(" - ");
       result.append(Tools.formatNumber(Math.abs(value)) + " * " + attributeNames[j]);
     }
     result.append(Tools.getLineSeparator());
   }
   return result.toString();
 }
 /** @return a <code>String</code> representation of this boosting model. */
 @Override
 public String toString() {
   StringBuffer result =
       new StringBuffer(
           super.toString()
               + Tools.getLineSeparator()
               + "Number of inner models: "
               + this.getNumberOfModels()
               + Tools.getLineSeparators(2));
   for (int i = 0; i < this.getNumberOfModels(); i++) {
     Model model = this.getModel(i);
     result.append(
         (i > 0 ? Tools.getLineSeparator() : "")
             + "Embedded model #"
             + i
             + " (weight: "
             + Tools.formatNumber(this.getWeightForModel(i))
             + "): "
             + Tools.getLineSeparator()
             + model.toResultString());
   }
   return result.toString();
 }
Пример #13
0
    /** Returns a label that displays the {@link #toResultString()} result encoded as html. */
    public java.awt.Component getVisualizationComponent(IOContainer container) {
      StringBuffer buffer = new StringBuffer();
      Color bgColor = SwingTools.LIGHTEST_YELLOW;
      String bgColorString =
          "#"
              + Integer.toHexString(bgColor.getRed())
              + Integer.toHexString(bgColor.getGreen())
              + Integer.toHexString(bgColor.getBlue());
      Color headerColor = SwingTools.LIGHTEST_BLUE;
      String headerColorString =
          "#"
              + Integer.toHexString(headerColor.getRed())
              + Integer.toHexString(headerColor.getGreen())
              + Integer.toHexString(headerColor.getBlue());
      buffer.append("<table bgcolor=\"" + bgColorString + "\" border=\"1\">");
      buffer.append(
          "<tr bgcolor=\""
              + headerColorString
              + "\"><th>Source</th><th>Square Sums</th><th>DF</th><th>Mean Squares</th><th>F</th><th>Prob</th></tr>");
      buffer.append(
          "<tr><td>Between</td><td>"
              + Tools.formatNumber(sumSquaresBetween)
              + "</td><td>"
              + df1
              + "</td><td>"
              + Tools.formatNumber(meanSquaresBetween)
              + "</td><td>"
              + Tools.formatNumber(fValue)
              + "</td><td>"
              + Tools.formatNumber(prob)
              + "</td></tr>");
      buffer.append(
          "<tr><td>Residuals</td><td>"
              + Tools.formatNumber(sumSquaresResiduals)
              + "</td><td>"
              + df2
              + "</td><td>"
              + Tools.formatNumber(meanSquaresResiduals)
              + "</td><td></td><td></td></tr>");
      buffer.append(
          "<tr><td>Total</td><td>"
              + Tools.formatNumber(sumSquaresBetween + sumSquaresResiduals)
              + "</td><td>"
              + (df1 + df2)
              + "</td><td></td><td></td><td></td></tr>");
      buffer.append("</table>");
      buffer.append(
          "<br>Probability for random values with the same result: "
              + Tools.formatNumber(prob)
              + "<br>");
      if (prob < alpha)
        buffer.append(
            "Difference between actual mean values is probably significant, since "
                + Tools.formatNumber(prob)
                + " &lt; alpha = "
                + Tools.formatNumber(alpha)
                + "!");
      else
        buffer.append(
            "Difference between actual mean values is probably not significant, since "
                + Tools.formatNumber(prob)
                + " &gt; alpha = "
                + Tools.formatNumber(alpha)
                + "!");

      JEditorPane textPane =
          new JEditorPane(
              "text/html", "<html><h1>" + getName() + "</h1>" + buffer.toString() + "</html>");
      textPane.setBackground((new JLabel()).getBackground());
      textPane.setBorder(javax.swing.BorderFactory.createEmptyBorder(11, 11, 11, 11));
      return new ExtendedJScrollPane(textPane);
    }
  private void addRuleNodes(boolean[] filter) {
    Iterator<String> e = edgeList.iterator();
    while (e.hasNext()) {
      graph.removeEdge(e.next());
    }

    Iterator<String> n = nodeList.iterator();
    while (n.hasNext()) {
      graph.removeVertex(n.next());
    }

    edgeList.clear();
    nodeList.clear();

    toolTipInfos.clear();
    asPremise.clear();
    asConclusion.clear();

    int ruleIndex = 1;
    for (int r = 0; r < rules.getNumberOfRules(); r++) {
      if (filter[r]) {
        AssociationRule rule = rules.getRule(r);

        // define conjunction node
        String conjunctionNode =
            "Rule "
                + ruleIndex
                + " ("
                + Tools.formatNumber(rule.getTotalSupport())
                + " / "
                + Tools.formatNumber(rule.getConfidence())
                + ")";
        toolTipInfos.put(
            conjunctionNode,
            "<html><b>Rule "
                + ruleIndex
                + "</b><br>"
                + SwingTools.addLinebreaks(
                    rule.toPremiseString() + " --> " + rule.toConclusionString())
                + "<br><b>Support:</b> "
                + rule.getTotalSupport()
                + "<br><b>Confidence:</b> "
                + rule.getConfidence()
                + "<br><b>Lift:</b> "
                + rule.getLift()
                + "<br><b>Gain:</b> "
                + rule.getGain()
                + "<br><b>Conviction:</b> "
                + rule.getConviction()
                + "<br><b>Laplace:</b> "
                + rule.getLaplace()
                + "<br><b>Ps:</b> "
                + rule.getPs()
                + "</html>");
        nodeList.add(conjunctionNode);

        // add premise nodes
        Iterator<Item> p = rule.getPremiseItems();
        while (p.hasNext()) {
          Item premiseItem = p.next();
          String edgeId = edgeFactory.create();
          edgeList.add(edgeId);
          nodeList.add(premiseItem.toString());
          graph.addEdge(edgeId, premiseItem.toString(), conjunctionNode);
          List<String> premiseList = asPremise.get(premiseItem.toString());
          if (premiseList == null) {
            premiseList = new LinkedList<String>();
            asPremise.put(premiseItem.toString(), premiseList);
          }
          premiseList.add("Rule " + ruleIndex);
        }

        // add conclusion nodes
        Iterator<Item> c = rule.getConclusionItems();
        while (c.hasNext()) {
          Item conclusionItem = c.next();
          String edgeId = edgeFactory.create();
          edgeList.add(edgeId);
          nodeList.add(conclusionItem.toString());
          graph.addEdge(edgeId, conjunctionNode, conclusionItem.toString());
          List<String> conclusionList = asConclusion.get(conclusionItem.toString());
          if (conclusionList == null) {
            conclusionList = new LinkedList<String>();
            asConclusion.put(conclusionItem.toString(), conclusionList);
          }
          conclusionList.add("Rule " + ruleIndex);
        }
      }
      ruleIndex++;
    }
  }
 @Override
 public String toString() {
   return "Relative neighborhood with a fraction of "
       + Tools.formatNumber(relativeSize, 3)
       + " of the complete data set";
 }