View source: R/decomp_metrics.R
| decomp_metrics | R Documentation |
Quantify a fitted decomposition: how much of the data its components reconstruct, how redundant they are, and – given data the fit never saw – whether it generalizes.
decomp_metrics(
decom,
x,
new_data = NULL,
execution_config = NULL,
verbosity = 1L
)
decom |
|
x |
Tabular data (data.frame, data.table, or tibble): The data |
new_data |
Optional tabular data: Data the fit never saw. Its columns
must match those |
execution_config |
Optional |
verbosity |
Integer: Verbosity level. |
Which metrics are computed follows from the algorithm's traits; see
applicable_metrics. A metric its algorithm cannot support is NA.
The unprefixed metrics describe the fitted data, so x must be that data:
they are computed against the components decom already holds. A different
number of cases is an error, and x failing to match
decom@data_fingerprint is reported without raising, since scoring a fit
against an altered copy of its training data is a legitimate thing to do.
decomp() already stores this on its result for the data it was fitted on,
so calling this without new_data recomputes what decom@metrics holds. The
reason to call it is new_data: reconstruction_gap is the difference
between out-of-sample and in-sample relative reconstruction error, and it is
the signal that a decomposition has fitted its training cases rather than
their structure.
Reconstruction is measured in the units of the data as it was passed to
decomp(), so the numbers are comparable across algorithms and across
configurations of one algorithm. One caveat: ICA with row_norm = TRUE
standardizes each case across features, and inverting that needs each case's
own mean and standard deviation, taken from the data being reconstructed.
Its reconstruction therefore draws on information the components do not
carry, and its error is not comparable with an algorithm that reconstructs
from components alone.
DecompositionMetrics object.
EDG
x <- exc(iris, "Species")
iris_pca <- decomp(x, algorithm = "PCA", verbosity = 0L)
decomp_metrics(iris_pca, x, verbosity = 0L)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.