@Override
 public void close() {
   if (attributeEditor.hasDataChanged()) {
     int selectedOption =
         JOptionPane.showConfirmDialog(
             this,
             "It seems that you have changed the data without saving it afterwards."
                 + Tools.getLineSeparator()
                 + "Do you still want to proceed and close the editor (changes will be lost)?",
             "Save data file?",
             JOptionPane.YES_NO_OPTION,
             JOptionPane.QUESTION_MESSAGE);
     if (selectedOption == JOptionPane.YES_OPTION) dispose();
   } else if (attributeEditor.hasMetaDataChanged()) {
     int selectedOption =
         JOptionPane.showConfirmDialog(
             this,
             "It seems that you have changed the attribute descriptions without saving an attribute description file (.aml) afterwards."
                 + Tools.getLineSeparator()
                 + "Do you still want to proceed and close the editor (changes will be lost)?",
             "Save attribute description file?",
             JOptionPane.YES_NO_OPTION,
             JOptionPane.QUESTION_MESSAGE);
     if (selectedOption == JOptionPane.YES_OPTION) dispose();
   } else {
     dispose();
   }
 }
Esempio n. 2
0
 public String getHTMLMessage() {
   return "<html>Error occured:<br>"
       + Tools.escapeXML(getMessage())
       + "<hr>"
       + Tools.escapeXML(getDetails())
       + "</html>";
 }
 @Override
 public String getColumnName(int columnIndex) {
   if (config != null) {
     return Tools.getExcelColumnName(columnIndex + config.getColumnOffset());
   } else {
     return Tools.getExcelColumnName(columnIndex);
   }
 }
 @Override
 public String toString() {
   updateDistributionProperties();
   return ("Normal distribution --> mean: "
       + Tools.formatNumber(mean)
       + ", standard deviation: "
       + Tools.formatNumber(standardDeviation));
 }
Esempio n. 5
0
 public String toString() {
   return "ANOVA result (f="
       + Tools.formatNumber(fValue)
       + ", prob="
       + Tools.formatNumber(prob)
       + ", alpha="
       + Tools.formatNumber(alpha)
       + ")";
 }
Esempio n. 6
0
 @Override
 public String toString() {
   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());
   }
   return result.toString();
 }
 /**
  * Returns a string representation of value. If the numberOfDigits is greater than 0 this number
  * is used to format the string. Otherwise the value of the system property
  * rapidminer.gui.fractiondigits.numbers will be used (see {@link com.rapidminer.tools.Tools} in
  * case of DEFAULT_NUMBER_OF_DIGITS or an unlimited number of digits in case of
  * UNLIMITED_NUMBER_OF_DIGITS. For the value NaN a &quot;?&quot; will be returned.
  */
 public String getAsString(double value, int numberOfDigits, boolean quoteNominal) {
   if (Double.isNaN(value)) {
     return "?";
   } else {
     switch (numberOfDigits) {
       case UNLIMITED_NUMBER_OF_DIGITS:
         return Double.toString(value);
       case DEFAULT_NUMBER_OF_DIGITS:
         return com.rapidminer.tools.Tools.formatIntegerIfPossible(value, -1);
       default:
         return com.rapidminer.tools.Tools.formatIntegerIfPossible(value, numberOfDigits);
     }
   }
 }
 public String toString(int maxNumber) {
   Collections.sort(associationRules);
   StringBuffer buffer = new StringBuffer("Association Rules" + Tools.getLineSeparator());
   int counter = 0;
   for (AssociationRule rule : associationRules) {
     if ((maxNumber >= 0) && (counter > maxNumber)) {
       buffer.append("... " + (associationRules.size() - maxNumber) + " other rules ...");
       break;
     }
     buffer.append(rule.toString());
     buffer.append(Tools.getLineSeparator());
     counter++;
   }
   return buffer.toString();
 }
  /** @return the text for the beta eula */
  private String loadBetaEULA() {
    String eulaText = null;
    // read EULA text
    try (InputStream inputStream = Tools.getResourceInputStream(BETA_EULA)) {
      eulaText = Tools.readTextFile(inputStream);
    } catch (IOException | RepositoryException e2) {
      // loading the EULA failed (this should never happen)
      LogService.getRoot()
          .log(
              Level.SEVERE,
              "com.rapidminer.gui.properties.BetaFeaturesListener.cannot_open_beta_eula");
    }

    return eulaText;
  }
Esempio n. 10
0
 @Override
 public String toString() {
   StringBuffer result = new StringBuffer(Tools.getLineSeparator() + "PerformanceVector [");
   for (int i = 0; i < size(); i++) {
     Averagable avg = getAveragable(i);
     if ((mainCriterion != null) && (avg.getName().equals(mainCriterion))) {
       result.append(Tools.getLineSeparator() + "*****");
     } else {
       result.append(Tools.getLineSeparator() + "-----");
     }
     result.append(avg);
   }
   result.append(Tools.getLineSeparator() + "]");
   return result.toString();
 }
    @Override
    public Object getValueAt(int row, int column) {
      Object[] values = data.get(row);

      if (column == 0) {
        return values[column].toString();
      }

      if (column >= values.length) {
        return "";
      }
      int attributeType = reader.getAttributeColumn(column - 1).getValueType();

      if (Ontology.ATTRIBUTE_VALUE_TYPE.isA(attributeType, Ontology.DATE_TIME)
          || Ontology.ATTRIBUTE_VALUE_TYPE.isA(attributeType, Ontology.DATE_TIME)
          || Ontology.ATTRIBUTE_VALUE_TYPE.isA(attributeType, Ontology.TIME)) {
        try {
          return Tools.formatDateTime((Date) values[column]);
        } catch (ClassCastException e) {
          // do nothing, just return default value
        }
      }
      // default value
      return values[column].toString();
    }
  /** Trains a model using an ExampleSet from the input. Uses the method learn(ExampleSet). */
  @Override
  public void doWork() throws OperatorException {
    ExampleSet exampleSet = exampleSetInput.getData(ExampleSet.class);

    // some checks
    if (exampleSet.getAttributes().getLabel() == null) {
      throw new UserError(this, 105, new Object[0]);
    }
    if (exampleSet.getAttributes().size() == 0) {
      throw new UserError(this, 106, new Object[0]);
    }

    // check capabilities and produce errors if they are not fulfilled
    CapabilityCheck check =
        new CapabilityCheck(
            this,
            Tools.booleanValue(
                ParameterService.getParameterValue(
                    CapabilityProvider.PROPERTY_RAPIDMINER_GENERAL_CAPABILITIES_WARN),
                true));
    check.checkLearnerCapabilities(this, exampleSet);

    Model model = learn(exampleSet);

    modelOutput.deliver(model);
    exampleSetOutput.deliver(exampleSet);
  }
 public Object getValueAt(int row, int col) {
   if (col == 0) {
     return matrix.getAnovaAttributeNames().get(row);
   } else {
     return Tools.formatNumber(matrix.getProbabilities()[row][col - 1]);
   }
 }
 private void dump(ProcessResponse pInfo, PrintStream out) {
   out.println("State of process " + pInfo.getProcessLocation() + " (id=" + pInfo.getId() + ")");
   out.println("  Started:   " + pInfo.getStartTime());
   if (pInfo.getCompletionTime() != null) {
     out.println("  Completed: " + pInfo.getCompletionTime());
   }
   out.println("  State:     " + pInfo.getState());
   if (pInfo.getException() != null) {
     out.println("  Exception: " + pInfo.getException());
   }
   final ProcessStackTrace trace = pInfo.getTrace();
   if (trace != null) {
     out.println("  Trace:");
     for (ProcessStackTraceElement ste : trace.getElements()) {
       System.out.println(
           "     "
               + ste.getOperatorName()
               + " ("
               + ste.getApplyCount()
               + ", "
               + Tools.formatDuration(ste.getExecutionTime())
               + ")");
     }
   }
 }
 protected String createProcessTree(
     int indent, String selfPrefix, String childPrefix, Operator markOperator, String mark) {
   String tree = Tools.indent(indent) + " subprocess '" + getName() + "'";
   Iterator<Operator> i = operators.iterator();
   while (i.hasNext()) {
     tree +=
         Tools.getLineSeparator()
             + i.next()
                 .createProcessTree(
                     indent,
                     childPrefix + "+- ",
                     childPrefix + (i.hasNext() ? "|  " : "   "),
                     markOperator,
                     mark);
   }
   return tree;
 }
 @Override
 public void storeXML(String xml) throws RepositoryException {
   try {
     Tools.writeTextFile(getFile(), xml);
   } catch (IOException e) {
     throw new RepositoryException("Cannot write " + getFile() + ": " + e, e);
   }
 }
 @Override
 public String retrieveXML() throws RepositoryException {
   try {
     return Tools.readTextFile(getFile());
   } catch (IOException e) {
     throw new RepositoryException("Cannot read " + getFile() + ": " + e, e);
   }
 }
 @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;
 }
Esempio n. 19
0
 @Override
 public String toString() {
   StringBuffer buffer = new StringBuffer();
   if ((classPositive != null) && (classNegative != null))
     buffer.append(
         "Hyperplane seperating "
             + classPositive
             + " and "
             + classNegative
             + "."
             + Tools.getLineSeparator());
   else buffer.append("Hyperplane for linear regression." + Tools.getLineSeparator());
   buffer.append("Intercept: ");
   buffer.append(Double.toString(intercept));
   buffer.append(Tools.getLineSeparator());
   buffer.append("Coefficients: " + Tools.getLineSeparator());
   int counter = 0;
   for (double value : coefficients) {
     buffer.append(
         "w("
             + coefficientNames[counter]
             + ") = "
             + Tools.formatIntegerIfPossible(value, 3)
             + Tools.getLineSeparator());
     counter++;
   }
   buffer.append(Tools.getLineSeparator());
   return buffer.toString();
 }
  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder();
    builder.append("Threshold: ");
    builder.append(threshold);
    builder.append(Tools.getLineSeparator());
    builder.append("first class: ");
    builder.append(zeroClass);
    builder.append(Tools.getLineSeparator());
    builder.append("second class: ");
    builder.append(oneClass);

    builder.append(Tools.getLineSeparator());
    builder.append("if confidence(" + oneClass + ") > " + threshold + " then " + oneClass);
    builder.append(Tools.getLineSeparator());
    builder.append("else " + zeroClass);
    return builder.toString();
  }
 @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 String toString() {
   StringBuffer result =
       new StringBuffer(
           "IOContainer (" + ioObjects.size() + " objects):" + Tools.getLineSeparator());
   Iterator i = ioObjects.iterator();
   while (i.hasNext()) {
     IOObject current = (IOObject) i.next();
     if (current != null) {
       result.append(
           current.toString()
               + Tools.getLineSeparator()
               + (current.getSource() != null
                   ? "(created by " + current.getSource() + ")" + Tools.getLineSeparator()
                   : ""));
     }
   }
   return result.toString();
 }
  @Override
  public String toResultString() {
    StringBuilder builder = new StringBuilder();

    builder.append(
        "Denormalization Model of the following Normalization:" + Tools.getLineSeparator());
    builder.append(invertedModel.toResultString());

    return builder.toString();
  }
 private void save() {
   File file = SwingTools.chooseFile(null, null, true, "wgt", "attribute weight file");
   try {
     attributeTableModel
         .getAttributeWeights()
         .writeAttributeWeights(file, Tools.getDefaultEncoding());
   } catch (IOException e) {
     SwingTools.showSimpleErrorMessage("cannot_write_attr_weights_to_file", e, file.getName());
   }
 }
 @Override
 public String getColumnName(int columnIndex) {
   if (columnIndex == 0) { // RowNo.
     return "Row No.";
   }
   columnIndex--;
   // here the table header is implicitly set to the attributes name
   return Tools.getExcelColumnName(columnIndex);
   // return reader.getAttributeColumn(columnIndex).getName();
 }
 /** Sends the output to the LogService. */
 private void logOutput(String message, InputStream in) throws IOException {
   BufferedReader bin = new BufferedReader(new InputStreamReader(in));
   String line = null;
   StringBuffer buffer = new StringBuffer(message);
   while ((line = bin.readLine()) != null) {
     buffer.append(Tools.getLineSeparator());
     buffer.append(line);
   }
   logNote(buffer.toString());
 }
 @Override
 public String toString() {
   String output = "";
   if (!empty) {
     output +=
         "<html>"
             + "<span style=\"font-size:11px;margin:2px 0 2px 4px;\">"
             +
             // "Match "+number+": <b>'"+match+"'</b>" +
             I18N.getMessage(
                 I18N.getGUIBundle(),
                 "gui.dialog.parameter.regexp.regular_expression.result_list.match",
                 number,
                 "<b>'" + Tools.escapeHTML(match) + "'</b>")
             + "</span>";
     if (groups.length > 0) {
       output += "<ol style=\"margin:1px 0 0 24px\">";
       for (int i = 0; i < groups.length; i++) {
         // output += "<li>Group matches: <b>'" + groups[i] +"'</b></li>";
         output +=
             "<li>"
                 + I18N.getMessage(
                     I18N.getGUIBundle(),
                     "gui.dialog.parameter.regexp.regular_expression.result_list.group_match",
                     "<b>'" + Tools.escapeHTML(groups[i]) + "'</b>")
                 + "</li>";
       }
       output += "</ul>";
     }
     output += "</html>";
   } else {
     output +=
         "<html>"
             + "<span style=\"font-size:11px;margin:2px 0 2px 4px;\">"
             + I18N.getMessage(
                 I18N.getGUIBundle(),
                 "gui.dialog.parameter.regexp.regular_expression.result_list.empty")
             + "</span>";
     output += "</html>";
   }
   return output;
 }
Esempio n. 28
0
 @Override
 public String getHTMLMessage() {
   // return "<html>Error in: <b>" + getOperator() + "</b><br>" + Tools.escapeXML(getMessage())
   // + "<hr>" + Tools.escapeXML(getDetails()) +
   // "</html>";
   return "<html>Error in: <b>"
       + getOperator()
       + "</b><br>"
       + Tools.escapeXML(getMessage())
       + "</html>";
 }
Esempio n. 29
0
 /** @return a <code>String</code> representation of this scaling model. */
 @Override
 public String toString() {
   String result =
       super.toString()
           + " ("
           + this.parameters.toString()
           + ") "
           + Tools.getLineSeparator()
           + "Model: "
           + model.toResultString();
   return result;
 }
  @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);
  }