Search cross-validation: private API
PortfolioOptimisers.pipeline_lens — Function
pipeline_lens(pipe::Pipeline, key) -> lensResolve a tuning key into an Accessors.jl lens on a Pipeline.
A leading step name resolves to the step's position (name → index → property path): "gap_fill.fill" targets the fill field of the step named "gap_fill", and a bare step name ("gap_fill", :gap_fill) or an integer position targets the whole step — swapping entire estimators as grid values needs no extra syntax. A key whose leading segment is not a step name falls through to parse_lens only when it is rooted at steps, so raw property paths ("steps[2].fill", "steps[2]") and prebuilt lenses keep working.
A key that misses the step-name table and is not a path rooted at steps (see is_pipeline_raw_path) is rejected instead — "gapfill" is a typo, not a path, and "names[1]" addresses the step-name table, so reinterpreting either as a property access on the Pipeline struct tunes nothing at best and writes into a real field at worst. The Symbol arm fails closed on the same rule, and tests for a dot as well, because a symbol key never reaches Meta.parse.
Arguments
pipe: The pipeline being tuned.key: AGSCVKey: step name with optional trailing property path, integer step position, raw property path,Expr/Symbol, or a prebuilt lens.
Returns
lens: A composed Accessors.jl lens rooted at the pipeline.
Related
PortfolioOptimisers.is_pipeline_raw_path — Function
is_pipeline_raw_path(key::AbstractString) -> BoolReturn true when key is a raw property path rooted at the steps field of a Pipeline — "steps[1]", "steps[2].fill".
The predicate the AbstractString arm of pipeline_lens uses to separate a raw property path from a typo when the leading segment misses the step-name table. It names the one root a path may address instead of rejecting one shape. A Pipeline holds two fields, names and steps, and only steps holds the estimators a grid tunes, so "names[1]" is refused with "gapfill". An admitted key falls through to parse_lens.
The Symbol arm tests for a dot as well, because a symbol key is not run through Meta.parse: an index in a symbol is a character in a property name, not a lens path.
Related
PortfolioOptimisers.pipeline_lens_val_grid — Function
pipeline_lens_val_grid(
pipe::Pipeline,
estval::AbstractVector{<:Pair{<:Any, <:AbstractVector}}
) -> Tuple{Any, Any}
Build the (lens, value) grid for tuning a Pipeline — the pipeline-aware counterpart of lens_val_grid, resolving keys through pipeline_lens so step names and positions address steps.
Arguments
pipe: The pipeline being tuned.estval: The parameter grid:key => valuespairs, a dict, or a vector of either (independent grids concatenated).
Validation
- The candidate count must not exceed
RESOURCE_LIMITS[].max_search_grid, asserted byassert_search_grid_capbefore the product is materialised.
Returns
(lenses, vals): Per-candidate lens vectors and value tuples.
Related
PortfolioOptimisers.pipeline_data_view — Function
pipeline_data_view(pr::AbstractPricesResult, idx) -> Any
pipeline_data_view(
pr::AbstractPricesResult,
idx,
idx2
) -> Any
Return the observation-window view of price- or returns-level data used by pipeline search cross-validation.
Arguments
data: The input data (AbstractPricesResultorAbstractReturnsResult).idx: Observation window into the rows ofdata.
Returns
data′: The windowed data at the same level.
Related
PortfolioOptimisers.cv_data_eltype — Function
cv_data_eltype(rd::AbstractReturnsResult) -> Any
Return the element type search-CV score matrices use for the given data level.
Related