Class TimeSeriesBagOfFeaturesClassifier
- java.lang.Object
-
- ai.libs.jaicore.ml.tsc.classifier.ASimplifiedTSClassifier<java.lang.Integer>
-
- ai.libs.jaicore.ml.tsc.classifier.trees.TimeSeriesBagOfFeaturesClassifier
-
public class TimeSeriesBagOfFeaturesClassifier extends ASimplifiedTSClassifier<java.lang.Integer>
Implementation of the Time Series Bag-of-Features (TSBF) classifier as described in Baydogan, Mustafa & Runger, George & Tuv, Eugene. (2013). A Bag-of-Features Framework to Classify Time Series. IEEE Transactions on Pattern Analysis and Machine Intelligence. 35. 2796-802. 10.1109/TPAMI.2013.72. This classifier only supports univariate time series prediction.
-
-
Field Summary
-
Fields inherited from class ai.libs.jaicore.ml.tsc.classifier.ASimplifiedTSClassifier
classMapper, trained
-
-
Constructor Summary
Constructors Constructor Description TimeSeriesBagOfFeaturesClassifier(int seed)Standard constructor using the default parameters (numBins = 10, numFolds = 10, zProp = 0.1, minIntervalLength = 5) for the TSBF classifier.TimeSeriesBagOfFeaturesClassifier(int seed, int numBins, int numFolds, double zProp, int minIntervalLength)Constructor specifying parameters (cf.TimeSeriesBagOfFeaturesClassifier(int seed, int numBins, int numFolds, double zProp, int minIntervalLength, boolean useZNormalization)Constructor specifying parameters (cf.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TimeSeriesBagOfFeaturesLearningAlgorithm.ITimeSeriesBagOfFeaturesConfiggetConfig()weka.classifiers.trees.RandomForestgetFinalClf()int[][][]getIntervals()TimeSeriesBagOfFeaturesLearningAlgorithmgetLearningAlgorithm(TimeSeriesDataset dataset)intgetNumBins()intgetNumClasses()int[][]getSubsequences()weka.classifiers.trees.RandomForestgetSubseriesClf()java.lang.Integerpredict(double[] univInstance)Method predicting the class of the givenunivInstance.java.util.List<java.lang.Integer>predict(TimeSeriesDataset dataset)Performs predictions based on the given instances in the given dataset.java.lang.Integerpredict(java.util.List<double[]> multivInstance)Performs a prediction based on the given multivariate list of double[] instance representation and returns the result.voidsetFinalClf(weka.classifiers.trees.RandomForest finalClf)voidsetIntervals(int[][][] intervals)voidsetNumBins(int numBins)voidsetNumClasses(int numClasses)voidsetSubsequences(int[][] subsequences)voidsetSubseriesClf(weka.classifiers.trees.RandomForest subseriesClf)-
Methods inherited from class ai.libs.jaicore.ml.tsc.classifier.ASimplifiedTSClassifier
checkWhetherPredictionIsPossible, getClassMapper, isTrained, setClassMapper, train
-
-
-
-
Constructor Detail
-
TimeSeriesBagOfFeaturesClassifier
public TimeSeriesBagOfFeaturesClassifier(int seed)
Standard constructor using the default parameters (numBins = 10, numFolds = 10, zProp = 0.1, minIntervalLength = 5) for the TSBF classifier.- Parameters:
seed- Seed used for randomized operations
-
TimeSeriesBagOfFeaturesClassifier
public TimeSeriesBagOfFeaturesClassifier(int seed, int numBins, int numFolds, double zProp, int minIntervalLength)Constructor specifying parameters (cf.TimeSeriesBagOfFeaturesClassifier(int)).- Parameters:
seed- Seed used for randomized operationsnumBins- SeeTimeSeriesBagOfFeaturesClassifier#numBinsnumFolds- Number of folds for the internal OOB probability CV estimationzProp- Proportion of the total time series length to be used for the subseries generationminIntervalLength- The minimal interval length used for the interval generation
-
TimeSeriesBagOfFeaturesClassifier
public TimeSeriesBagOfFeaturesClassifier(int seed, int numBins, int numFolds, double zProp, int minIntervalLength, boolean useZNormalization)Constructor specifying parameters (cf.TimeSeriesBagOfFeaturesClassifier(int)).- Parameters:
seed- Seed used for randomized operationsnumBins- SeeTimeSeriesBagOfFeaturesClassifier#numBinsnumFolds- Number of folds for the internal OOB probability CV estimationzProp- Proportion of the total time series length to be used for the subseries generationminIntervalLength- The minimal interval length used for the interval generationuseZNormalization- Indicator whether the Z normalization should be used
-
-
Method Detail
-
predict
public java.lang.Integer predict(double[] univInstance) throws PredictionExceptionMethod predicting the class of the givenunivInstance. At first, an internal feature representation using a bag of features is generated by the previously trainedsubsequencesandintervals. These internal instances are used to get an internal class probability estimation for each subsequence and interval for each instance using a Random Forest classifier. These probabilities are aggregated to a histogram which is then fed to a final Random Forest classifier predicting the instance's target class.- Specified by:
predictin classASimplifiedTSClassifier<java.lang.Integer>- Parameters:
univInstance- Univariate instance given by a double vector of time series values used for the prediction- Returns:
- Returns the result of the prediction
- Throws:
PredictionException- If something fails during the prediction process.
-
predict
public java.lang.Integer predict(java.util.List<double[]> multivInstance) throws PredictionExceptionPerforms a prediction based on the given multivariate list of double[] instance representation and returns the result.- Overrides:
predictin classASimplifiedTSClassifier<java.lang.Integer>- Parameters:
multivInstance- Multivariate instance given by a list of multiple double[] time series used for the prediction- Returns:
- Returns the result of the prediction
- Throws:
PredictionException- If something fails during the prediction process.
-
predict
public java.util.List<java.lang.Integer> predict(TimeSeriesDataset dataset) throws PredictionException
Performs predictions based on the given instances in the given dataset.- Specified by:
predictin classASimplifiedTSClassifier<java.lang.Integer>- Parameters:
dataset- TheTimeSeriesDatasetfor which predictions should be made.- Returns:
- Returns the result of the predictions
- Throws:
PredictionException- If something fails during the prediction process
-
getSubseriesClf
public weka.classifiers.trees.RandomForest getSubseriesClf()
- Returns:
- the subseriesClf
-
setSubseriesClf
public void setSubseriesClf(weka.classifiers.trees.RandomForest subseriesClf)
- Parameters:
subseriesClf- the subseriesClf to set
-
getFinalClf
public weka.classifiers.trees.RandomForest getFinalClf()
- Returns:
- the finalClf
-
setFinalClf
public void setFinalClf(weka.classifiers.trees.RandomForest finalClf)
- Parameters:
finalClf- the finalClf to set
-
getNumBins
public int getNumBins()
- Returns:
- the numBins
-
setNumBins
public void setNumBins(int numBins)
- Parameters:
numBins- the numBins to set
-
getNumClasses
public int getNumClasses()
- Returns:
- the numClasses
-
setNumClasses
public void setNumClasses(int numClasses)
- Parameters:
numClasses- the numClasses to set
-
getIntervals
public int[][][] getIntervals()
- Returns:
- the intervals
-
setIntervals
public void setIntervals(int[][][] intervals)
- Parameters:
intervals- the intervals to set
-
getSubsequences
public int[][] getSubsequences()
- Returns:
- the subsequences
-
setSubsequences
public void setSubsequences(int[][] subsequences)
- Parameters:
subsequences- the subsequences to set
-
getLearningAlgorithm
public TimeSeriesBagOfFeaturesLearningAlgorithm getLearningAlgorithm(TimeSeriesDataset dataset)
- Specified by:
getLearningAlgorithmin classASimplifiedTSClassifier<java.lang.Integer>
-
getConfig
public TimeSeriesBagOfFeaturesLearningAlgorithm.ITimeSeriesBagOfFeaturesConfig getConfig()
-
-