public class ShotgunEnsembleClassifier extends ASimplifiedTSClassifier<java.lang.Integer>
ShotgunEnsembleAlgoritm determines for
specific window lengths the number of correct predicitions on the training
data using the leave-one-out technique. The bestScore is the
highest number of correct predicitions over all window lengths. Given a
factor in (0,1], the window lengths where
correct * factor > bestScore are used in an ensemble of Shotgun
Classifiers to create an overall predicition.| Modifier and Type | Field and Description |
|---|---|
protected int |
bestScore
The best score.
|
protected double |
factor
Factor used to determine whether or not to include a window length into the
overall predicition.
|
protected NearestNeighborClassifier |
nearestNeighborClassifier
The nearest neighbor classifier used for prediction.
|
protected ShotgunDistance |
shotgunDistance
The Shotgun Distance used by the
nearestNeighborClassifier. |
protected int[] |
targets
Target values for the instances.
|
protected double[][] |
values
Value matrix containing the time series instances.
|
protected java.util.ArrayList<ai.libs.jaicore.basic.sets.Pair<java.lang.Integer,java.lang.Integer>> |
windows
Holds pairs of (number of correct predictions, window length) obtained in
training phase.
|
classMapper, trained| Constructor and Description |
|---|
ShotgunEnsembleClassifier(int minWindowLength,
int maxWindowLength,
boolean meanNormalization,
double factor)
Creates a Shotgun Ensemble classifier.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.util.Map<java.lang.Integer,java.lang.Integer> |
calculateWindowLengthPredictions(double[] testInstance)
Calculates predicitions for a test instance using 1NN with Shotgun Distance
and different window lengths.
|
protected java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> |
calculateWindowLengthPredictions(TimeSeriesDataset dataset)
Calculates predicitions for a test dataset using 1NN with Shotgun Distance
and different window lengths.
|
ShotgunEnsembleLearnerAlgorithm |
getLearningAlgorithm(TimeSeriesDataset dataset) |
protected java.lang.Integer |
mostFrequentLabelFromWindowLengthPredicitions(java.util.Map<java.lang.Integer,java.lang.Integer> windowLengthPredicitions)
Returns the most frequent predicition given a Map of (window length,
prediciton) pairs.
|
protected java.util.List<java.lang.Integer> |
mostFrequentLabelsFromWindowLengthPredicitions(java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> windowLengthPredicitions)
Returns for each instance the most frequent predicitions as contained in a
Map of (window length, list of prediciton for each instance) pairs.
|
java.lang.Integer |
predict(double[] univInstance)
Predicts on univariate instance.
|
java.lang.Integer |
predict(java.util.List<double[]> multivInstance)
Predicts on a multivariate instance.
|
java.util.List<java.lang.Integer> |
predict(TimeSeriesDataset dataset)
Predicts on a dataset.
|
protected void |
setNearestNeighborClassifier(NearestNeighborClassifier nearestNeighborClassifier)
Sets the nearest neighbor classifier,
nearestNeighborClassifier. |
protected void |
setTargets(int[] targets)
Sets the targets.
|
protected void |
setValues(double[][] values)
Sets the value matrix.
|
protected void |
setWindows(java.util.ArrayList<ai.libs.jaicore.basic.sets.Pair<java.lang.Integer,java.lang.Integer>> windows)
Sets the windows and also retreives and sets the @see #bestScore from these
windows.
|
getClassMapper, isTrained, setClassMapper, trainprotected double factor
protected double[][] values
protected int[] targets
protected NearestNeighborClassifier nearestNeighborClassifier
protected ShotgunDistance shotgunDistance
nearestNeighborClassifier. Set by
the algorithm.protected java.util.ArrayList<ai.libs.jaicore.basic.sets.Pair<java.lang.Integer,java.lang.Integer>> windows
protected int bestScore
public ShotgunEnsembleClassifier(int minWindowLength,
int maxWindowLength,
boolean meanNormalization,
double factor)
algorithm - The training algorithm.factor - Factor used to determine whether or not to include a window
length into the overall predicition.protected java.util.Map<java.lang.Integer,java.lang.Integer> calculateWindowLengthPredictions(double[] testInstance)
throws PredictionException
testInstance - The test instance.PredictionExceptionprotected java.lang.Integer mostFrequentLabelFromWindowLengthPredicitions(java.util.Map<java.lang.Integer,java.lang.Integer> windowLengthPredicitions)
windowLengthPredicitions - Map of (window length, prediciton) pairs.protected java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> calculateWindowLengthPredictions(TimeSeriesDataset dataset) throws PredictionException
dataset - The dataset to predict for.PredictionExceptionprotected java.util.List<java.lang.Integer> mostFrequentLabelsFromWindowLengthPredicitions(java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> windowLengthPredicitions)
windowLengthPredicitions - Map of (window length, list of prediciton for
each instance) pairs.public java.lang.Integer predict(double[] univInstance)
throws PredictionException
predict in class ASimplifiedTSClassifier<java.lang.Integer>univInstance - The univariate instance.PredictionException - If something fails during the prediction process.public java.lang.Integer predict(java.util.List<double[]> multivInstance)
throws PredictionException
predict in class ASimplifiedTSClassifier<java.lang.Integer>multivInstance - The multivariate instance.PredictionException - If something fails during the prediction process.public java.util.List<java.lang.Integer> predict(TimeSeriesDataset dataset) throws PredictionException
predict in class ASimplifiedTSClassifier<java.lang.Integer>dataset - The dataset.PredictionException - If something fails during the prediction processprotected void setValues(double[][] values)
values - protected void setTargets(int[] targets)
targets - protected void setWindows(java.util.ArrayList<ai.libs.jaicore.basic.sets.Pair<java.lang.Integer,java.lang.Integer>> windows)
windows - @see #windowsprotected void setNearestNeighborClassifier(NearestNeighborClassifier nearestNeighborClassifier)
nearestNeighborClassifier.nearestNeighborClassifier - public ShotgunEnsembleLearnerAlgorithm getLearningAlgorithm(TimeSeriesDataset dataset)
getLearningAlgorithm in class ASimplifiedTSClassifier<java.lang.Integer>