prea.data.preparation
Class KfoldCrossValidation
java.lang.Object
prea.data.preparation.DatasetManager
prea.data.preparation.KfoldCrossValidation
public class KfoldCrossValidation
- extends DatasetManager
This class implements K-fold cross-validation.
- Since:
- 2012. 3. 26
- Version:
- 1.1
- Author:
- Joonseok Lee
Fields inherited from class prea.data.preparation.DatasetManager |
itemCount, itemRateAverage, K_FOLD_CROSS_VALIDATION, maxValue, minValue, PREDEFINED_SPLIT, rateMatrix, SIMPLE_SPLIT, testMatrix, userCount, userRateAverage |
Method Summary |
private void |
divideFolds(int k)
Divide the original rating matrix into k-fold. |
SparseMatrix |
getKthFold(int k)
Return the k-th fold as test set (testMatrix),
making all the others as train set in rateMatrix. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
assign
private SparseMatrix assign
foldCount
private int foldCount
KfoldCrossValidation
public KfoldCrossValidation(SparseMatrix originalMatrix,
int k,
int max,
int min)
- Construct an instance for K-fold cross-validation.
divideFolds
private void divideFolds(int k)
- Divide the original rating matrix into k-fold.
Illegal k would be adjusted automatically.
- Parameters:
k
- The index for desired fold.
getKthFold
public SparseMatrix getKthFold(int k)
- Return the k-th fold as test set (testMatrix),
making all the others as train set in rateMatrix.
- Parameters:
k
- The index for desired fold.
- Returns:
- Rating matrix with test data with data points in k-th fold.