| add_model_metadata | R Documentation |
spectral_model objectThis function has two use cases:
i. If object (being a spectral_model object) is passed to the
function, it returns the same object with the specified model metadata added
to it.
ii. Otherwise, the function creates a a list of model metadata that can be used
as input for the argument metadata of the calibrate function.
add_model_metadata(object, key = UUIDgenerate(), created, changed,
name = c("", NULL), sort_order = 1, tol_min = NULL,
tol_max = NULL, decimal_places = 2, unit = "",
mahal_limit = 5, corrections = c(bias = 0, slope = 1),
limit_min = NULL, limit_max = NULL, target = NULL,
wavelength_range = c("Nir", "Vis", "Nir+Vis"),
predict_type = "Calibration", arguments = rep("", 4))
object |
an optional object of class |
key |
a string for the key of the model. Defaults to a newly
generated key using |
created |
a string for date and time of the addition of the model to the application. Default is the current date and time of the system. See details for the format in which it has to be provided. |
changed |
a string for date and time when the model has been changed. Default is the current date and time of the system. See details for the format in which it has to be provided. |
name |
a vector of character strings of length 2 for the name and alias
of the property. If |
sort_order |
a numeric, indicating the order in which the properties are shown on a ProxiMate device. Defaults to 1. |
tol_min |
an optional numeric for the minimum error tolerance.
Defaults to |
tol_max |
an optional numeric for the maximal error tolerance.
Defaults to |
decimal_places |
a numeric for the decimal precision of the measurements of the property. Defaults to 2. |
unit |
a string for the units in which the reference values of the property are measured. Defaults to an empty character. |
mahal_limit |
a numeric for the maximum Mahalanobis distance allowed. Defaults to 5. |
corrections |
a vector of numerics of length 2 for bias and slope
corrections. Defaults to no corrections, i.e. |
limit_min |
an optional numeric for the lower limit of the reference
values. Defaults to |
limit_max |
an optional numeric for the upper limit of the reference
values. Defaults to |
target |
an optional numeric for the desired predicted reference values.
Defaults to |
wavelength_range |
a string for the considered wavelength range of the
spectrum. Must be one of |
predict_type |
a string for the prediction type of the model. Defaults
to |
arguments |
a vector of maximal length 4. Contains additional arguments to be saved into the metadata. Defaults to a vector of empty characters of length 4. |
This function has two functionalities:
If object (being a spectral_model object) is passed
to the function, it returns the same object with the specified property
metadata added to it.
Otherwise, the function creates a a list of property metadata
that can be used as the argument metadata of the calibrate function.
The two-fold functionality of this function allows to add metadata during the
construction of the model, or after the model-building has been finished.
For the former, the model has to be passed in object, and the returned
value of this function contains the model including the chosen metadata.
In the latter case, the returned value of this function may be passed to the
parameter metadata of function calibrate.
A lot of the parameters can be left unchanged and may be adjusted at a later stage of the application development (e.g. in a ProxiMate device).
The parameters created and changed must contain the date
(YYYY-MM-DD) and time (HH:MM:SS), seperated by a single
"T" (without any spaces). For example, the following code returns
the correct format (also, both created and changed default to this
value):
gsub(" ", "T", format(Sys.time()))
Either the spectral_model object with the added property metadata
(if object is provided), or the property metadata, which is a named list.
Claudio Orellano, Leonardo Ramirez-Lopez
calibrate, proximate_write_nax
data(proximateCannabis)
# Downview Absorbance of CBDA in percentage
downview_metadata <- add_model_metadata(
name = "CBDA",
unit = "%",
arguments = "Example metadata"
)
# Three ways to add metadata to spectral_model object:
# As a direct argument
simple_model <- calibrate(CBDA ~ spc,
data = proximateCannabis, preprocess = preprocess_recipe(),
method = fit_plsr(5), control = calibration_control(),
metadata = downview_metadata
)
# Passing the model to add_model_metadata
simple_model <- add_model_metadata(
object = simple_model,
name = "CBDA",
unit = "%",
arguments = "Example metadata"
)
# Adding it directly (not recommended)
simple_model$metadata <- downview_metadata
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.