Methods
RandomFeatures.Methods.RandomFeatureMethod — Type
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 objectbatch_sizes::Dict{S, Int64} where S<:AbstractString: A dictionary specifying the batch sizes. Must contain "train", "test", and "feature" keysregularization::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 covariancetullio_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.
RandomFeatures.Methods.Fit — Type
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: TheLinearAlgrebamatrix decomposition of(1 / m) * Feature^T * regularization^-1 * Feature + Icoeffs::AbstractVector: Coefficients of the fit to dataregularization::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.
RandomFeatures.Methods.get_random_feature — Function
get_random_feature(
rfm::RandomFeatureMethod
) -> RandomFeature
gets the random_feature field
RandomFeatures.Methods.get_batch_sizes — Function
get_batch_sizes(
rfm::RandomFeatureMethod
) -> Dict{S, Int64} where S<:AbstractString
gets the batch_sizes field
RandomFeatures.Methods.get_batch_size — Function
get_batch_size(
rfm::RandomFeatureMethod,
key::AbstractString
) -> Int64
get the specified batch size from batch_sizes field
RandomFeatures.Methods.get_regularization — Function
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
get_regularization(
f::Fit
) -> Union{LinearAlgebra.UniformScaling, AbstractMatrix}
gets the regularization field (note this is the outputdim regularization)
RandomFeatures.Methods.get_tullio_threading — Function
get_tullio_threading(rfm::RandomFeatureMethod) -> Bool
gets the tullio_threading field
StatsBase.sample — Method
sample(rfm::RandomFeatureMethod) -> Any
samples the random_feature field
RandomFeatures.Methods.get_feature_factors — Function
get_feature_factors(f::Fit) -> Decomposition
gets the feature_factors field
RandomFeatures.Methods.get_coeffs — Function
get_coeffs(f::Fit) -> AbstractVector
gets the coeffs field
StatsAPI.fit — Function
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.
StatsAPI.predict — Function
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.
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:`outputdim
xn_samples` - covstore:`outputdim
xoutputdimxnsamples` - buffer:
n_samplesxoutput_dimxn_features
RandomFeatures.Methods.predictive_mean — Function
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.
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.
RandomFeatures.Methods.predictive_cov — Function
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.
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-allocatedoutput_dim × output_dim × n_samplesarray for the covariance output.buffer: pre-allocatedn_samples × output_dim × n_featuresworking array.prebuilt_features:n_samples × output_dim × n_featuresfeature matrix.
RandomFeatures.Methods.predict_prior — Function
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
RandomFeatures.Methods.predict_prior_mean — Function
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
RandomFeatures.Methods.predict_prior_cov — Function
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