Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.jstacs.classifier.scoringFunctionBased.sampling
Class SamplingScoreBasedClassifier.ScoringFunctionSamplingComponent

    java.lang.Object
      de.jstacs.classifier.scoringFunctionBased.sampling.SamplingScoreBasedClassifier.ScoringFunctionSamplingComponent

All Implemented Interfaces:
  SamplingComponent

Enclosing class:
  SamplingScoreBasedClassifier

    protected class SamplingScoreBasedClassifier.ScoringFunctionSamplingComponent

extends Object
implements SamplingComponent

The `SamplingComponent` that handles storing and loading sampled parameters values to and from files.

Author:
  Jan Grau

Constructor Summary
`SamplingScoreBasedClassifier.ScoringFunctionSamplingComponent(String outfilePrefix)` Creates a new `SamplingScoreBasedClassifier.ScoringFunctionSamplingComponent` that uses temporary files with name prefix `outfilePrefix` to store sampled parameters.

Method Summary
`void` | `acceptParameters()` This methods accepts the drawn parameters.
`protected void` | `createFiles(StringBuffer contents)` Creates files out of file contents saved as XML.
`void` | `extendSampling(int sampling, boolean append)` This method allows to extend a sampling.
`void` | `initForSampling(int starts)` This method initializes the instance for the sampling.
`boolean` | `isInSamplingMode()` This method returns `true` if the object is currently used in a sampling, otherwise `false`.
`boolean` | `joinAndSetParameterFiles(boolean add, File[] files)` Combines parameter files such that they are accepted as parameter files of the calling `SamplingScoreBasedClassifier`
`boolean` | `parseNextParameterSet()` This method allows the user to parse the next set of parameters (from a file).
`boolean` | `parseParameterSet(int sampling, int n)` This method allows the user to parse the set of parameters with index `n` of a certain `sampling` (from a file).
`void` | `samplingStopped()` This method is the opposite of the method `SamplingComponent.extendSampling(int, boolean)`.
`protected StringBuffer` | `saveParameters()` Saves the parameter values of all parameter files to a `StringBuffer` representing these as XML.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SamplingScoreBasedClassifier.ScoringFunctionSamplingComponent

    public SamplingScoreBasedClassifier.ScoringFunctionSamplingComponent(String outfilePrefix)

  Creates a new `SamplingScoreBasedClassifier.ScoringFunctionSamplingComponent` that uses temporary files with name prefix `outfilePrefix` to store sampled parameters. These files are either stored in the default temp directory of the OS, or, if specified, in the directory set by `SamplingScoreBasedClassifier.setTempDir(File)` before starting the sampling process.

  Parameters:
    `outfilePrefix` - the prefix of the parameter files

Method Detail

### joinAndSetParameterFiles

    public boolean joinAndSetParameterFiles(boolean add,
                                            File[] files)
                                     throws Exception

  Combines parameter files such that they are accepted as parameter files of the calling `SamplingScoreBasedClassifier`

  Parameters:
    `add` - if true, parameter files are appended to the current ones, i.e., the number of samplings is augmented by these files
    `files` - the parameter files
  Returns:
    `true` if the parameters coul be joined
  Throws:
    `Exception` - if the parameter files could not be loaded

### parseParameterSet

    public boolean parseParameterSet(int sampling,
                                     int n)
                              throws Exception

  Description copied from interface: `SamplingComponent`
  This method allows the user to parse the set of parameters with index `n` of a certain `sampling` (from a file). The internal numbering should start with 0. The parameter set with index 0 is the initial (random) parameter set. It is recommended that a series of parameter sets is accessed by the following lines:

  `for( sampling = 0; sampling < numSampling; sampling++ )
  { boolean b = parseParameterSet( sampling, n );
  while( b )
  {
  //do something
  b = parseNextParameterSet();
  } }
  `

  Specified by:
    `parseParameterSet` in interface `SamplingComponent`
  Parameters:
    `sampling` - the index of the sampling
    `n` - the index of the parameter set
  Returns:
    `true` if the parameter set could be parsed
  Throws:
    `Exception` - if there is a problem with parsing the parameters
  See Also:
    `SamplingComponent.parseNextParameterSet()`

### parseNextParameterSet

    public boolean parseNextParameterSet()

  Description copied from interface: `SamplingComponent`
  This method allows the user to parse the next set of parameters (from a file).

  Specified by:
    `parseNextParameterSet` in interface `SamplingComponent`
  Returns:
    `true` if the parameters could be parsed, otherwise `false`
  See Also:
    `SamplingComponent.parseParameterSet(int, int)`

### initForSampling

    public void initForSampling(int starts)
                         throws IOException

  Description copied from interface: `SamplingComponent`
  This method initializes the instance for the sampling. For instance this method can be used to create new files where all parameter sets are stored.

  Specified by:
    `initForSampling` in interface `SamplingComponent`
  Parameters:
    `starts` - the number of different sampling starts that will be done
  Throws:
    `IOException` - if something went wrong
  See Also:
    `File.createTempFile(String, String, java.io.File )`

### extendSampling

    public void extendSampling(int sampling,
                               boolean append)
                        throws IOException

  Description copied from interface: `SamplingComponent`
  This method allows to extend a sampling.

  Specified by:
    `extendSampling` in interface `SamplingComponent`
  Parameters:
    `sampling` - the index of the sampling
    `append` - whether to append the sampled parameters to an existing file or to overwrite the file
  Throws:
    `IOException` - if the file could not be handled correctly

### samplingStopped

    public void samplingStopped()
                         throws IOException

  Description copied from interface: `SamplingComponent`
  This method is the opposite of the method `SamplingComponent.extendSampling(int, boolean)`. It can be used for closing any streams of writer, ...

  Specified by:
    `samplingStopped` in interface `SamplingComponent`
  Throws:
    `IOException` - if something went wrong
  See Also:
    `SamplingComponent.extendSampling(int, boolean)`

### isInSamplingMode

    public boolean isInSamplingMode()

  Description copied from interface: `SamplingComponent`
  This method returns `true` if the object is currently used in a sampling, otherwise `false`.

  Specified by:
    `isInSamplingMode` in interface `SamplingComponent`
  Returns:
    `true` if the object is currently used in a sampling, otherwise `false`

### acceptParameters

    public void acceptParameters()
                          throws IOException

  Description copied from interface: `SamplingComponent`
  This methods accepts the drawn parameters. Internally the drawn parameters should be saved (to a file).

  Specified by:
    `acceptParameters` in interface `SamplingComponent`
  Throws:
    `IOException` - if the file could not be handled correctly

### saveParameters

    protected StringBuffer saveParameters()
                                   throws IOException

  Saves the parameter values of all parameter files to a `StringBuffer` representing these as XML.

  Returns:
    the `StringBuffer` containing the parameters
  Throws:
    `IOException` - if the files could not be read

### createFiles

    protected void createFiles(StringBuffer contents)
                        throws NonParsableException,
                               IOException

  Creates files out of file contents saved as XML.

  Parameters:
    `contents` - the parameter values to be stored in the files
  Throws:
    `NonParsableException` - if the parameters could not be parsed
    `IOException` - if the files could not be written
  See Also:
    `saveParameters()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD