Package planner.utils
Class CrossValidation
java.lang.Object
planner.utils.CrossValidation
CrossValidation is a class which integrates the data and mechanisms needed
for running a basic k-fold cross validation.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Alicia Vazquez Ramos
-
Constructor Summary
ConstructorsConstructorDescriptionCrossValidation
(Dataset d, int k) Constructor of the mechanisms need for running a k-fold cross validation: given a dataset and a value for k, shuffles and splits the set of instances stored in the dataset. -
Method Summary
Modifier and TypeMethodDescriptionArrayList<double[]>
Gets the current active partition for the cross validation.ArrayList<double[]>
Gets the current active test partition for the cross validation.ArrayList<double[]>
Gets the current active training partition for the cross validation.int
getK()
Gets the number of folds, k, in k-CVdouble[]
Gets the real prediction values stored for each instance of the active partition.double[]
Gets the real prediction values stored for each instance of the active training partition.boolean
boolean
void
void
void
Updates the current active training partition and the current active test partition for running the cross validation updating the set of instances used for training those used for testing.double
-
Constructor Details
-
CrossValidation
Constructor of the mechanisms need for running a k-fold cross validation: given a dataset and a value for k, shuffles and splits the set of instances stored in the dataset.- Parameters:
d
- dataset of the problem.k
- number of division in the k-fold cross validation process.
-
-
Method Details
-
isTraining
public boolean isTraining() -
isTesting
public boolean isTesting() -
setTrainingState
public void setTrainingState() -
setTestingState
public void setTestingState() -
getK
public int getK()Gets the number of folds, k, in k-CV- Returns:
- number of folds.
-
getActivePartition
Gets the current active partition for the cross validation. Can be changed to be the test or training partition by setting testing or training mode.- Returns:
- the active partition.
-
getActiveTestPartition
Gets the current active test partition for the cross validation.- Returns:
- the active test partition.
-
getActiveTrainingPartition
Gets the current active training partition for the cross validation.- Returns:
- the active training partition.
-
getRealValPartition
public double[] getRealValPartition()Gets the real prediction values stored for each instance of the active partition.- Returns:
- an array of real prediction values.
-
getRealValTrainingPartition
public double[] getRealValTrainingPartition()Gets the real prediction values stored for each instance of the active training partition.- Returns:
- an array of real prediction values.
-
updatePartitions
public void updatePartitions()Updates the current active training partition and the current active test partition for running the cross validation updating the set of instances used for training those used for testing. -
validate
-