|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.classifiers.differentiableSequenceScoreBased.sampling.SamplingScoreBasedClassifier.DiffSMSamplingComponent
protected class SamplingScoreBasedClassifier.DiffSMSamplingComponent
The SamplingComponent
that handles storing and loading sampled parameters values
to and from files.
Constructor Summary | |
---|---|
SamplingScoreBasedClassifier.DiffSMSamplingComponent(String outfilePrefix)
Creates a new SamplingScoreBasedClassifier.DiffSMSamplingComponent 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 |
---|
public SamplingScoreBasedClassifier.DiffSMSamplingComponent(String outfilePrefix)
SamplingScoreBasedClassifier.DiffSMSamplingComponent
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.
outfilePrefix
- the prefix of the parameter filesMethod Detail |
---|
public boolean joinAndSetParameterFiles(boolean add, File[] files) throws Exception
SamplingScoreBasedClassifier
add
- if true, parameter files are appended to the current ones, i.e., the number
of samplings is augmented by these filesfiles
- the parameter files
true
if the parameters could be joined
Exception
- if the parameter files could not be loadedpublic boolean parseParameterSet(int sampling, int n) throws Exception
SamplingComponent
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();
}
}
parseParameterSet
in interface SamplingComponent
sampling
- the index of the samplingn
- the index of the parameter set
true
if the parameter set could be parsed
Exception
- if there is a problem with parsing the parametersSamplingComponent.parseNextParameterSet()
public boolean parseNextParameterSet()
SamplingComponent
parseNextParameterSet
in interface SamplingComponent
true
if the parameters could be parsed, otherwise
false
SamplingComponent.parseParameterSet(int, int)
public void initForSampling(int starts) throws IOException
SamplingComponent
initForSampling
in interface SamplingComponent
starts
- the number of different sampling starts that will be done
IOException
- if something went wrongFile.createTempFile(String, String, java.io.File )
public void extendSampling(int sampling, boolean append) throws IOException
SamplingComponent
extendSampling
in interface SamplingComponent
sampling
- the index of the samplingappend
- whether to append the sampled parameters to an existing file
or to overwrite the file
IOException
- if the file could not be handled correctlypublic void samplingStopped() throws IOException
SamplingComponent
SamplingComponent.extendSampling(int, boolean)
. It can be
used for closing any streams of writer, ...
samplingStopped
in interface SamplingComponent
IOException
- if something went wrongSamplingComponent.extendSampling(int, boolean)
public boolean isInSamplingMode()
SamplingComponent
true
if the object is currently used in
a sampling, otherwise false
.
isInSamplingMode
in interface SamplingComponent
true
if the object is currently used in a sampling,
otherwise false
public void acceptParameters() throws IOException
SamplingComponent
acceptParameters
in interface SamplingComponent
IOException
- if the file could not be handled correctlyprotected StringBuffer saveParameters() throws IOException
StringBuffer
representing these as XML.
StringBuffer
containing the parameters
IOException
- if the files could not be readprotected void createFiles(StringBuffer contents) throws NonParsableException, IOException
contents
- the parameter values to be stored in the files
NonParsableException
- if the parameters could not be parsed
IOException
- if the files could not be writtensaveParameters()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |