com.rapidminer.example
Class ExampleFormatter

java.lang.Object
  extended by com.rapidminer.example.ExampleFormatter

public class ExampleFormatter
extends java.lang.Object

Formats an example as specified by the format string. The dollar sign '$' is an escape character. Squared brackets '[' and ']' have a special meaning. The following escape sequences are interpreted:

$a:
All attributes separated by the default separator
$a[separator]:
All attributes separated by separator
$s[separator][indexSeparator]:
Sparse format. For all non 0 attributes the following strings are concatenated: the column index, the value of indexSeparator, the attribute value. Attributes are separated by separator.
$v[name]:
The value of the attribute with the given name (both regular and special attributes)
$k[index]:
The value of the attribute with the given index in the example set
$l:
The label
$p:
The predicted label
$d:
All prediction confidences for all classes in the form conf(class)=value
$d[class]:
The prediction confidence for the defined class as a simple number
$i:
The id
$w:
The weight
$c:
The cluster
$b:
The batch
$n:
The newline character
$t:
The tabulator character
$$:
The dollar sign
$[:
The '[' character
$]:
The ']' character

Author:
Simon Fischer, Ingo Mierswa Exp $

Nested Class Summary
static interface ExampleFormatter.FormatCommand
          Represents one piece of formatting.
static class ExampleFormatter.SimpleCommand
          Implements some simple format commands like 'a' for all attributes or 'l' for the label.
static class ExampleFormatter.TextCommand
          Returns simply the given text.
static class ExampleFormatter.ValueCommand
          Returns the value of an argument which must be an attribute's name.
 
Constructor Summary
ExampleFormatter(ExampleFormatter.FormatCommand[] formatCommands)
          Constructs a new ExampleFormatter that executes the given array of formatting commands.
 
Method Summary
static ExampleFormatter compile(java.lang.String formatString, ExampleSet exampleSet, int fractionDigits, boolean quoteWhitespace)
          Factory method that compiles a format string and creates an instance of ExampleFormatter.
 java.lang.String format(Example example)
          Formats a single example.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExampleFormatter

public ExampleFormatter(ExampleFormatter.FormatCommand[] formatCommands)
Constructs a new ExampleFormatter that executes the given array of formatting commands. The preferred way of creating an instance of ExampleFormatter is to compile(String, ExampleSet, int, boolean) a format string.

Method Detail

compile

public static ExampleFormatter compile(java.lang.String formatString,
                                       ExampleSet exampleSet,
                                       int fractionDigits,
                                       boolean quoteWhitespace)
                                throws FormatterException
Factory method that compiles a format string and creates an instance of ExampleFormatter.

Throws:
FormatterException

format

public java.lang.String format(Example example)
Formats a single example.



Copyright © 2001-2009 by Rapid-I