Combinatorial: private API
PortfolioOptimisers.CombCVER — Type
const CombCVER = Union{<:CombinatorialCrossValidation,
<:CombinatorialCrossValidationResult}Alias for a combinatorial cross-validation estimator or result.
Matches either a CombinatorialCrossValidation estimator or a CombinatorialCrossValidationResult.
Related
PortfolioOptimisers.test_set_index — Method
test_set_index(ccv)Generate all test set index combinations for combinatorial cross-validation.
Each element is one split's test set, given as the n_test_folds fold indices it holds. The elements are fold indices, not observation indices, and the splits come in the order Combinatorics.combinations enumerates them.
Arguments
ccv:CombinatorialCrossValidationconfiguration.
Returns
Vector{Vector{Int}}of lengthn_splits.
Related
PortfolioOptimisers.binary_train_test_sets — Method
binary_train_test_sets(ccv)Generate the binary train/test fold assignment matrix for combinatorial cross-validation.
The rows are folds and the columns are splits. An entry is true when that fold is a test fold of that split, and false when it is a training fold. The assignment is over folds, not over observations.
Arguments
ccv:CombinatorialCrossValidationconfiguration.
Returns
BitMatrixof size(n_folds, n_splits).
Related
PortfolioOptimisers.get_path_ids — Method
get_path_ids(ccv)Get path identifiers for each test fold of each split in combinatorial cross-validation.
This is the transpose of the view recombined_paths gives. The rows are the test folds of a split and the columns are splits. Entry (m, j) is the path that the m-th test block of split j belongs to, where the blocks of a split are counted in ascending observation order. This is the path_ids field of CombinatorialCrossValidationResult, and it is what pairs each block of test_idx[j] with its path.
Arguments
ccv:CombinatorialCrossValidationconfiguration.
Returns
Matrix{Int}of size(n_test_folds, n_splits).
Related
PortfolioOptimisers.n_test_paths — Function
n_test_paths(n_folds, n_test_folds)
n_test_paths(ccv::CombinatorialCrossValidation)Compute the number of test paths in combinatorial cross-validation.
Returns the number of unique recombined test paths from n_folds folds choosing n_test_folds test folds. Also accepts a CombinatorialCrossValidation object directly.
The count is div(binomial(n_folds, n_test_folds) * n_test_folds, n_folds), which is the $\varphi(n,\, k)$ of CombinatorialCrossValidation. Each fold is a test fold in the same number of splits, so the test blocks recombine into exactly this many paths, and each path covers every observation once.
Arguments
n_folds: Total number of folds.n_test_folds: Number of test folds per combination.ccv:CombinatorialCrossValidationconfiguration, which supplies both counts.
Returns
- Integer number of test paths.
Related
PortfolioOptimisers.average_train_size — Function
average_train_size(T, n_folds, n_test_folds)
average_train_size(ccv::CombinatorialCrossValidation, rd::Prices_RR)Compute the average training set size for combinatorial cross-validation.
The count is T / n_folds * (n_folds - n_test_folds), taken before purging and embargoing, so the training set of a split with a non-zero purged_size or embargo_size is smaller than this.
Arguments
T: Total number of observations.n_folds: Total number of folds.n_test_folds: Number of test folds per combination.ccv:CombinatorialCrossValidationconfiguration, which suppliesn_foldsandn_test_folds.rd: Returns-level or price-level data, which suppliesTthroughcv_nobs(Prices_RR).
Returns
- Average number of training observations per split.
Related
PortfolioOptimisers.recombined_paths — Function
recombined_paths(ccv)Generate the recombined test paths for combinatorial cross-validation.
The rows are folds and the columns are paths. Entry (f, p) is the index of the split that supplies fold f to path p. Reading one column therefore names one split per fold, and those blocks together cover every observation exactly once.
Arguments
ccv:CombinatorialCrossValidationconfiguration.
Returns
Matrix{Int}of size(n_folds, n_test_paths).
Related