Randomised search cross validation
PortfolioOptimisers.RandomisedSearchCrossValidation Type
struct RandomisedSearchCrossValidation{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10} <:
AbstractSearchCrossValidationEstimator
p::T1
cv::T2
r::T3
scorer::T4
ex::T5
n_iter::T6
rng::T7
seed::T8
train_score::T9
kwargs::T10
endRandomised search cross-validation estimator for portfolio optimisation. Samples parameter sets from distributions or vectors, applies cross-validation splits, fits and scores each configuration, and selects the optimal parameters using the provided scoring strategy.
Fields
p: Parameter grid, supporting vectors, dictionaries, or distributions for random sampling. If all parameters in a grid are vectors they are sampled uniformly without replacement, if at least one of them is a distribution they are sampled with replacement. When sampling without replacement the sampling is performed up until the list of candidates is exhausted. If a vector of grids, each grid is sampled independently and then they're all concatenated.cv: Cross-validation splitter.r: Risk measure used for scoring.scorer: Scoring function to select optimal parameter set.ex: Parallel execution strategy.n_iter: Number of random parameter sets to sample.rng: Random number generator for reproducibility.seed: Optional seed for RNG.train_score: Whether to record training scores.kwargs: Additional keyword arguments for customisation.
Constructors
RandomisedSearchCrossValidation(p::Union{AbstractVector{<:Pair{<:AbstractString, <:Any}},
AbstractVector{<:AbstractVector{<:Pair{<:AbstractString,
<:Any}}},
AbstractDict{<:AbstractString, <:Any},
AbstractVector{<:AbstractDict{<:AbstractString,
<:Any}}};
cv::SearchCV = KFold(),
r::AbstractBaseRiskMeasure = ConditionalValueatRisk(),
scorer::CrossValSearchScorer = HighestMeanScore(),
ex::FLoops.Transducers.Executor = FLoops.ThreadedEx(),
n_iter::Integer = 10,
rng::Random.AbstractRNG = Random.default_rng(),
seed::Option{<:Integer} = nothing,
train_score::Bool = false, kwargs::NamedTuple = (;))Keyword arguments correspond to the fields above.
Validation
Parameter grid
pmust not be empty.All parameter values must be vectors or distributions.
For nested parameter grids, each must not be empty.
n_itermust be non-empty, greater than zero, and finite.
Examples
julia> RandomisedSearchCrossValidation(Dict("alpha" => [0.1, 0.2, 0.3],
"beta" => Normal(1.0, 0.5)))
RandomisedSearchCrossValidation
p ┼ Dict{String, Any}: Dict{String, Any}("alpha" => [0.1, 0.2, 0.3], "beta" => Distributions.Normal{Float64}(μ=1.0, σ=0.5))
cv ┼ KFold
│ n ┼ Int64: 5
│ purged_size ┼ Int64: 0
│ embargo_size ┴ Int64: 0
r ┼ ConditionalValueatRisk
│ settings ┼ RiskMeasureSettings
│ │ scale ┼ Float64: 1.0
│ │ ub ┼ nothing
│ │ rke ┴ Bool: true
│ alpha ┼ Float64: 0.05
│ w ┴ nothing
scorer ┼ HighestMeanScore()
ex ┼ Transducers.ThreadedEx{@NamedTuple{}}: Transducers.ThreadedEx()
n_iter ┼ Int64: 10
rng ┼ Random.TaskLocalRNG: Random.TaskLocalRNG()
seed ┼ nothing
train_score ┼ Bool: false
kwargs ┴ @NamedTuple{}: NamedTuple()Related
[
AbstractSearchCrossValidationEstimator]-(@ref)
PortfolioOptimisers.search_cross_validation Method
search_cross_validation(opt::NonFiniteAllocationOptimisationEstimator,
rscv::RandomisedSearchCrossValidation,
rd::ReturnsResult)Performs randomised search cross-validation for portfolio optimisation estimators. Samples parameter sets from distributions or vectors, applies cross-validation splits, fits and scores each configuration, and selects the optimal parameters using the provided scoring strategy.
Arguments
opt: Portfolio optimisation estimator to be tuned.rscv: Randomised search cross-validation estimator specifying parameter grid, CV splitter, risk measure, scorer, execution strategy, number of iterations, RNG, and options.rd: Returns result containing asset returns data.
Returns
SearchCrossValidationResult: Result type containing the optimal estimator, test and train scores, parameter grid, and selected index.
Validation
Sets RNG seed if provided.
Validates parameter grid and number of iterations.
Ensures sampled parameter sets are valid.
Details
Samples parameter sets from vectors or distributions.
Applies cross-validation splits to the returns data.
Fits the estimator for each sampled parameter set and split.
Scores each configuration using the specified risk measure and scoring function.
Selects the optimal parameter set based on cross-validation scores.
Returns a result object encapsulating the optimal estimator and score matrices.
Related
[
NonFiniteAllocationOptimisationEstimator]-(@ref)
Examples
source