View source: R/validate_prediction.R
| validate_prediction | R Documentation |
'spectral_prediction'Calculate several prediction validation statistics for a prediction of class
'spectral_prediction'.
validate_prediction(prediction, reference)
prediction |
an object of class |
reference |
a vector or a matrix with one column, containing the response variable. |
An object of class "spectral_validation", which is a list containing
the following validation statistics of the prediction:
model_information: A list containing information of the
model on which the predictions are based. Mirrors the very same list
contained in the prediction. See predict
for more details.
validation: A list with the validation statistics. For
each prediction contained in prediction (which are based on the
number of components), one entry in the list is added. Each of these
elements exactly one matrix and one vector: val_results contains
the predicted values and the corresponding errors in a matrix, while
val_stats is a vector consisting of the coefficient of determination
(\mjeqnR^2R^2), root mean squared error (RMSE) and the largest
residual obtained. These statistics are computed based on the prediction
and reference, while ignoring any NA's.
control_limits: A list carried over from the
prediction with the per-component control limits used by the
leverage-vs-Q plot: q (spectral residual Q limits), leverage
(leverage limits) and conf (their confidence level).
Claudio Orellano
data("proximateCannabis")
skips <- c(10, 25, 37)
simple_model <- calibrate(CBDA ~ spc,
data = proximateCannabis, preprocess = preprocess_recipe(),
method = fit_plsr(5), control = calibration_control("kfold"),
skips = skips, verbose = FALSE
)
# Predict the skipped indices
pred <- predict(simple_model,
newdata = proximateCannabis[skips, ],
ncomp = simple_model$final_ncomp,
verbose = FALSE
)
# Validate skipped indices
validate_prediction(pred, proximateCannabis$CBDA[skips])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.