S
- the type of observations.T
- the type of categories.public class GridSearchParameterLearner<S extends Observation,T extends Category> extends ParameterTrainer<S,T>
partitions
number of partitions. For each partition of each parameter the border points are chosen and a new
classifier is learned with given parameter combination. From all combinations the combination
where the classifier performs best is chosen. If depth
> 1, the process is iterated: after selecting
the best interval combination of the parameters, these intervals are again divided and the process
is repeated depth
many times.
Modifier and Type | Field and Description |
---|---|
private int |
depth
The depth of the recursion.
|
private int |
partitions
The number of partitions of each parameter interval.
|
private ClassificationTester<S,T> |
tester
The tester used for measuring the performance of each parameter combination.
|
Constructor and Description |
---|
GridSearchParameterLearner(Trainer<S,T> trainer,
ClassificationTester<S,T> tester,
int depth,
int partitions)
Creates a new grid-search parameter learner with the given arguments.
|
Modifier and Type | Method and Description |
---|---|
private ParameterSet |
adjustParameterSet(ParameterSet set,
int[] indices,
double[] lowerBounds,
double[] upperBounds)
Determine for all parameters of the set a new value, determined by partitioning [lowerBound,upperBound]
into this.partitions number of sub intervals and then taking the center point of the partition no.
|
private boolean |
increment(int[] indices,
int maxIdx)
Increments the given array of indices, e.g.
|
ParameterSet |
learnParameters(TrainingSet<S,T> trainingSet)
Learns the best parameters of the given trainer for the training set.
|
getParameterSet, getTrainer, setParameterSet, train, train
private int depth
private int partitions
private ClassificationTester<S extends Observation,T extends Category> tester
public GridSearchParameterLearner(Trainer<S,T> trainer, ClassificationTester<S,T> tester, int depth, int partitions)
trainer
- some trainer.tester
- some classification tester for measuring performance.depth
- the depth of the recursion.partitions
- the number of partitions.public ParameterSet learnParameters(TrainingSet<S,T> trainingSet)
ParameterTrainer
learnParameters
in class ParameterTrainer<S extends Observation,T extends Category>
trainingSet
- a training setprivate ParameterSet adjustParameterSet(ParameterSet set, int[] indices, double[] lowerBounds, double[] upperBounds)
set
- a parameter setindices
- indiceslowerBounds
- the lower boundsupperBounds
- the upper boundsprivate boolean increment(int[] indices, int maxIdx)
indices
- an array of ints.maxIdx
- the max index.