Package weka.classifiers
Class CrossValidationHelper
- java.lang.Object
-
- weka.classifiers.CrossValidationHelper
-
public class CrossValidationHelper extends Object
Helper class for cross-validation.- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description static String
PLACEHOLDER_CURRENTFOLD
the placeholder for the current fold number.static String
PLACEHOLDER_ORIGINAL
the placeholder for the (original) relation name.static String
PLACEHOLDER_TYPE
the placeholder for "train" or "test" type.
-
Constructor Summary
Constructors Constructor Description CrossValidationHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int[]
alignIndices(int[] original)
Reorders the indices to align with the original data.static ArrayList<weka.classifiers.evaluation.Prediction>
alignPredictions(ArrayList<weka.classifiers.evaluation.Prediction> predictions, int[] original)
Reorders the predictions to align with the original data.static String
createRelationName(String relation, String template, int fold, boolean train)
Generates a relation name for the current fold.static int[]
crossValidationIndices(weka.core.Instances data, int folds, Random random)
Returns the indices from the original dataset for tracing the predictions back to the original dataset (stratified).static int[]
crossValidationIndices(weka.core.Instances data, int folds, Random random, boolean stratify)
Returns the indices from the original dataset for tracing the predictions back to the original dataset.static String
relationNameTemplateTipText()
Returns the tiptext for the relation name template.
-
-
-
Field Detail
-
PLACEHOLDER_ORIGINAL
public static final String PLACEHOLDER_ORIGINAL
the placeholder for the (original) relation name.- See Also:
- Constant Field Values
-
PLACEHOLDER_TYPE
public static final String PLACEHOLDER_TYPE
the placeholder for "train" or "test" type.- See Also:
- Constant Field Values
-
PLACEHOLDER_CURRENTFOLD
public static final String PLACEHOLDER_CURRENTFOLD
the placeholder for the current fold number.- See Also:
- Constant Field Values
-
-
Method Detail
-
crossValidationIndices
public static int[] crossValidationIndices(weka.core.Instances data, int folds, Random random)
Returns the indices from the original dataset for tracing the predictions back to the original dataset (stratified).- Parameters:
data
- the original datafolds
- the number of foldsrandom
- the random number generator- Returns:
- the indices
-
crossValidationIndices
public static int[] crossValidationIndices(weka.core.Instances data, int folds, Random random, boolean stratify)
Returns the indices from the original dataset for tracing the predictions back to the original dataset.- Parameters:
data
- the original datafolds
- the number of foldsrandom
- the random number generatorstratify
- whether to stratify- Returns:
- the indices
-
alignIndices
public static int[] alignIndices(int[] original)
Reorders the indices to align with the original data.- Parameters:
original
- the original indices- Returns:
- the aligned data
-
alignPredictions
public static ArrayList<weka.classifiers.evaluation.Prediction> alignPredictions(ArrayList<weka.classifiers.evaluation.Prediction> predictions, int[] original)
Reorders the predictions to align with the original data.- Parameters:
predictions
- the predictions to alignoriginal
- the original indices- Returns:
- the aligned data
-
createRelationName
public static String createRelationName(String relation, String template, int fold, boolean train)
Generates a relation name for the current fold.- Parameters:
relation
- the original relation nametemplate
- the template for the relation namefold
- the current foldtrain
- whether train or test set- Returns:
- the relation name
-
relationNameTemplateTipText
public static String relationNameTemplateTipText()
Returns the tiptext for the relation name template.- Returns:
- the tiptext
- See Also:
createRelationName(String, String, int, boolean)
-
-