Package planner.utils

Class CrossValidation

java.lang.Object
planner.utils.CrossValidation

public class CrossValidation extends Object
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 Details

    • CrossValidation

      public CrossValidation(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.
      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

      public ArrayList<double[]> 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

      public ArrayList<double[]> getActiveTestPartition()
      Gets the current active test partition for the cross validation.
      Returns:
      the active test partition.
    • getActiveTrainingPartition

      public ArrayList<double[]> 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

      public double validate(ObjectiveFunction of)