Methods

RandomFeatures.Methods.RandomFeatureMethodType
struct RandomFeatureMethod{S<:AbstractString, USorM<:Union{LinearAlgebra.UniformScaling, AbstractMatrix}}

Holds the configuration for a random feature regression model, including the feature object, batch sizes for training and prediction, and the regularisation matrix.

  • random_feature::RandomFeature: The random feature object

  • batch_sizes::Dict{S, Int64} where S<:AbstractString: A dictionary specifying the batch sizes. Must contain "train", "test", and "feature" keys

  • regularization::Union{LinearAlgebra.UniformScaling, AbstractMatrix}: A positive definite matrix used during the fit method to regularize the linear solve, interpreted as the inverse of the observational noise covariance

  • tullio_threading::Bool: Use multithreading provided by Tullio

Constructors

RandomFeatureMethod(random_feature; regularization, batch_sizes, tullio_threading, regularization_inverted) — see the constructor docstring for defaults and validation behaviour.

source
RandomFeatures.Methods.FitType
struct Fit{V<:(AbstractVector), USorM<:Union{LinearAlgebra.UniformScaling, AbstractMatrix}}

Holds the coefficients and matrix decomposition produced by fit, describing a trained random feature regression model. Pass to predict, predictive_mean, or predictive_cov to obtain predictions at new input locations.

  • feature_factors::Decomposition: The LinearAlgreba matrix decomposition of (1 / m) * Feature^T * regularization^-1 * Feature + I

  • coeffs::AbstractVector: Coefficients of the fit to data

  • regularization::Union{LinearAlgebra.UniformScaling, AbstractMatrix}: output-dim x output_dim matrix 'regularization^{-1}' used during fit

Constructors

Produced by fit(rfm, input_output_pairs; decomposition_type = "cholesky") — not intended to be constructed directly.

source
RandomFeatures.Methods.get_regularizationFunction
get_regularization(
    rfm::RandomFeatureMethod
) -> Union{LinearAlgebra.UniformScaling, AbstractMatrix}

gets the regularization field, this is the inverse of the provided matrix if keyword regularization_inverted = false

source
get_regularization(
    f::Fit
) -> Union{LinearAlgebra.UniformScaling, AbstractMatrix}

gets the regularization field (note this is the outputdim regularization)

source
StatsAPI.fitFunction
fit(
    rfm::RandomFeatureMethod,
    input_output_pairs::EnsembleKalmanProcesses.DataContainers.PairedDataContainer;
    decomposition_type
) -> Union{Fit{_A, USorM} where {_A<:(AbstractVector), T, USorM<:AbstractMatrix{T}}, Fit{_A, LinearAlgebra.UniformScaling{T}} where {_A<:(AbstractVector), T<:Number}}

Fits a RandomFeatureMethod to input-output data, optionally provide a preferred LinearAlgebra matrix decomposition. Returns a Fit object.

source
StatsAPI.predictFunction
predict(
    rfm::RandomFeatureMethod,
    fit::Fit,
    new_inputs::EnsembleKalmanProcesses.DataContainers.DataContainer;
    kwargs...
) -> Tuple{Any, Any}

Return the predictive mean and (co)variance of the fitted random feature model evaluated at new_inputs.

Returns a (mean, cov) tuple where mean is an output_dim × n_samples array and cov is an output_dim × output_dim × n_samples array.

source
StatsAPI.predict!Function
predict!(
    rfm::RandomFeatureMethod,
    fit::Fit,
    new_inputs::EnsembleKalmanProcesses.DataContainers.DataContainer,
    mean_store::AbstractMatrix{<:AbstractFloat},
    cov_store::AbstractArray{<:AbstractFloat, 3},
    buffer::AbstractArray{<:AbstractFloat, 3};
    kwargs...
)

Makes a prediction of mean and (co)variance of fitted features on new input data, overwriting the provided stores.

  • meanstore:`outputdimxn_samples`
  • covstore:`outputdimxoutputdimxnsamples`
  • buffer:n_samples x output_dim x n_features
source
RandomFeatures.Methods.predictive_meanFunction
predictive_mean(
    rfm::RandomFeatureMethod,
    fit::Fit,
    new_inputs::EnsembleKalmanProcesses.DataContainers.DataContainer;
    kwargs...
) -> Tuple{Any, Any}

Return the predictive mean of the fitted random feature model evaluated at new_inputs.

Returns a tuple (mean, features) where mean is an output_dim × n_samples array and features is the n_samples × output_dim × n_features feature matrix, which can be passed directly to predictive_cov to avoid rebuilding features.

source
RandomFeatures.Methods.predictive_mean!Function
predictive_mean!(
    rfm::RandomFeatureMethod,
    fit::Fit,
    new_inputs::EnsembleKalmanProcesses.DataContainers.DataContainer,
    mean_store::Matrix{<:AbstractFloat};
    kwargs...
) -> Any

Makes a prediction of mean of fitted features on new input data. Writes into a provided output_dim x n_samples array: mean_store.

source
RandomFeatures.Methods.predictive_covFunction
predictive_cov(
    rfm::RandomFeatureMethod,
    fit::Fit,
    new_inputs::EnsembleKalmanProcesses.DataContainers.DataContainer,
    prebuilt_features::AbstractArray{<:AbstractFloat, 3};
    kwargs...
) -> Any

Return the predictive covariance of the fitted random feature model evaluated at new_inputs, using prebuilt_features to avoid rebuilding the feature matrix.

Returns an output_dim × output_dim × n_samples array.

source
RandomFeatures.Methods.predictive_cov!Function
predictive_cov!(
    rfm::RandomFeatureMethod,
    fit::Fit,
    new_inputs::EnsembleKalmanProcesses.DataContainers.DataContainer,
    cov_store::AbstractArray{<:AbstractFloat, 3},
    buffer::AbstractArray{<:AbstractFloat, 3},
    prebuilt_features::AbstractArray{<:AbstractFloat, 3};
    tullio_threading,
    kwargs...
)

Compute the predictive covariance of the fitted random feature model at new_inputs, writing into pre-allocated arrays and using prebuilt_features to avoid rebuilding the feature matrix.

Arguments

  • cov_store: pre-allocated output_dim × output_dim × n_samples array for the covariance output.
  • buffer: pre-allocated n_samples × output_dim × n_features working array.
  • prebuilt_features: n_samples × output_dim × n_features feature matrix.
source
RandomFeatures.Methods.predict_priorFunction
predict_prior(
    rfm::RandomFeatureMethod,
    new_inputs::EnsembleKalmanProcesses.DataContainers.DataContainer;
    kwargs...
) -> Tuple{Any, Any}

Makes a prediction of mean and (co)variance with unfitted features on new input data

source
RandomFeatures.Methods.predict_prior_meanFunction
predict_prior_mean(
    rfm::RandomFeatureMethod,
    new_inputs::EnsembleKalmanProcesses.DataContainers.DataContainer;
    kwargs...
) -> Tuple{Any, Any}

Makes a prediction of mean with unfitted features on new input data

source
RandomFeatures.Methods.predict_prior_covFunction
predict_prior_cov(
    rfm::RandomFeatureMethod,
    new_inputs::EnsembleKalmanProcesses.DataContainers.DataContainer;
    kwargs...
) -> Tuple{Any, Any}

Makes a prediction of (co)variance with unfitted features on new input data

source