|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fu_berlin.ties.classify.Tuner
public class Tuner
This class provides support for iterative training, also called TUNE (Train-until-no-errors) training.
Instances of this class are not thread-safe and must be synchronized externally, if required.
Field Summary | |
---|---|
static String |
CONFIG_SPLIT_SEPARATPR
Configuration key: If given, the specified string is used to separate the training from the testing section of the corpus (e.g. "---") and the train split and test split values are ignored. |
static String |
CONFIG_TEST_SPLIT
Configuration key: The percentage of a corpus to use for testing (evaluation). |
static String |
CONFIG_TRAIN_SPLIT
Configuration key: The percentage of a corpus to use for training. |
static String |
CONFIG_TUNE
Configuration key: The maximum number of iterations used for TUNE (train until no error) training; if 1, training is incremental. |
static String |
CONFIG_TUNE_EACH
Configuration key: Whether to measure results after each TUNE iteration or only at the end of training. |
static String |
CONFIG_TUNE_SINCE
Configuration key: The training iteration after which to evaluate results for the first time if CONFIG_TUNE_EACH is enabled. |
static String |
CONFIG_TUNE_STOP
Configuration key: TUNE training is stopped if the training accuracy didn't improve for the specified number of iterations. |
Constructor Summary | |
---|---|
Tuner(float trainingSplit,
float testingSplit,
String splitSep,
int tuneRuns,
int tuneStopAfter,
boolean measureEachTUNE,
int startMeasureTUNE,
List tuneEvalList)
Creates a new instance. |
|
Tuner(TiesConfiguration config,
String suffix)
Creates a new instance. |
Method Summary | |
---|---|
boolean |
continueTraining(double[] currentAcc,
int i)
Whether to continue TUNE training after finishing an iteration. |
String |
getSplitSeparator()
If not null , the returned string should be used to separate
the training from the testing section of the corpus (e.g. "---") and
the train split and
test split values should be ignored. |
float |
getTestSplit()
Returns the percentage of a corpus to use for testing; if -1 , all remaining documents should be used. |
float |
getTrainSplit()
Returns the percentage of a corpus to use for training. |
Set<Integer> |
getTuneEvaluations()
Returns the set of iterations after which to evaluate TUNE training in addition to the last one; should be ignored if isTuneEach() is
true . |
int |
getTuneIterations()
Returns the maximum number of iterations used for TUNE (train until no error) training; if 1, training is incremental. |
int |
getTuneSince()
Returns the training iteration after which to evaluate results for the first time if isTuneEach() is enabled. |
int |
getTuneStop()
Returns the TUNE stopping criterion: TUNE training should be stopped if the training accuracy didn't improve for the specified number of iterations. |
boolean |
isTuneEach()
Whether to measure results after each TUNE iteration or only at the end of training. |
void |
reset()
Resets the state of this instance. |
void |
selectFiles(String[] allFiles,
List<String> trainFiles,
List<String> evalFiles)
Chooses files to use for training and files to use for evaluation, depending on the configured settings. |
boolean |
shouldEvaluate(boolean continueTraining,
int i)
Whether to evaluate results after this TUNE iteration. |
String |
toString()
Returns a string representation of this object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String CONFIG_SPLIT_SEPARATPR
public static final String CONFIG_TRAIN_SPLIT
public static final String CONFIG_TEST_SPLIT
public static final String CONFIG_TUNE
public static final String CONFIG_TUNE_STOP
public static final String CONFIG_TUNE_EACH
public static final String CONFIG_TUNE_SINCE
CONFIG_TUNE_EACH
is enabled.
Constructor Detail |
---|
public Tuner(TiesConfiguration config, String suffix)
config
- used to configure this instancesuffix
- an optional suffix used to
adapt
configuration keys; might be null
public Tuner(float trainingSplit, float testingSplit, String splitSep, int tuneRuns, int tuneStopAfter, boolean measureEachTUNE, int startMeasureTUNE, List tuneEvalList) throws IllegalArgumentException
trainingSplit
- the percentage of a corpus to use for trainingtestingSplit
- the percentage of a corpus to use for testing
(evaluation); if -1
, all remaining documents (1 -
trainingSplit
) are usedsplitSep
- if not null
, the specified string is used
to separate the training from the testing section of the corpus and
the train split and
test split values are ignored.tuneRuns
- the maximum number of iterations used for TUNE
(train until no error) training; if 1, training is incrementaltuneStopAfter
- TUNE training is stopped if the training accuracy
didn't improve for the specified number of iterations.measureEachTUNE
- whether to measure results after each TUNE
iteration or only at the end of trainingstartMeasureTUNE
- he training iteration after which to evaluate
results for the first time if measureEachTUNE
is enabled
(ignored otherwise)tuneEvalList
- A list of Integers or int Strings specifying
iterations after which to evaluate TUNE training in addition to the last
one; ignored if measureEachTUNE
is true
IllegalArgumentException
- if trainingSplit
is not
a percentage (larger than 1 or smaller than 0) or if
tuneRuns
is non-positiveMethod Detail |
---|
public boolean continueTraining(double[] currentAcc, int i)
currentAcc
- the list of accuracies for the just finished
TUNE iterationi
- the number of the just finished TUNE iterations,
counting starts with 1 not with 0
public float getTestSplit()
-1
, all remaining documents should be used.
public float getTrainSplit()
public Set<Integer> getTuneEvaluations()
isTuneEach()
is
true
.
public String getSplitSeparator()
null
, the returned string should be used to separate
the training from the testing section of the corpus (e.g. "---") and
the train split and
test split values should be ignored.
public int getTuneIterations()
getTuneEvaluations()
.
public int getTuneSince()
isTuneEach()
is enabled.
public int getTuneStop()
public boolean isTuneEach()
public void reset()
public void selectFiles(String[] allFiles, List<String> trainFiles, List<String> evalFiles) throws IllegalArgumentException
allFiles
- the array of file names to processtrainFiles
- populated with the files to use for training, will
be populated with the first getTrainSplit()
*
allFiles.length files; must initially be emptyevalFiles
- populated with the files to use for evaluation, will
be populated from the next getTestSplit()
*
allFiles.length remaining files (or all remaining files if test
split is negative); must initially be empty
IllegalArgumentException
- if the lists aren't emptypublic boolean shouldEvaluate(boolean continueTraining, int i)
continueTraining
- the result returned by the preceding call to
continueTraining(double[], int)
i
- the number of the just finished TUNE iterations,
counting starts with 1 not with 0
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |