| make_obs_matrices | R Documentation |
Converts a prepared data frame into the arrays needed for training or
evaluation: a 3-D sequence array Xseq (shape [N, K, p+1]) and
companion vectors pf, y, and sample weights w.
make_obs_matrices(
df,
x_inputs,
scaler,
K = 64L,
knot_grid = seq(0, 1, length.out = K),
pf_left = -2,
pf_right = 7.6,
wet_split_cm = NULL,
w_wet = 1,
w_dry = 1
)
df |
A prepared data frame (output of |
x_inputs |
Character vector of covariate column names. |
scaler |
A fitted scaler from |
K |
Number of knot points (default |
knot_grid |
Numeric vector of knot positions (default
|
pf_left |
Left boundary of the pF domain (default |
pf_right |
Right boundary of the pF domain (default |
wet_split_cm |
Matric head threshold, in centimetres, separating
wet from dry observations, or |
w_wet |
Sample weight for wet-end observations (default |
w_dry |
Sample weight for dry-end observations (default |
A named list:
Xseq3-D numeric array [N, K, p+1].
pfNumeric matrix [N, 1] of normalised pF values.
yNumeric matrix [N, 2]: columns are theta_n and
theta_max_n.
wNumeric vector of sample weights.
Rows of df with a missing covariate, matric_head or theta_n are
dropped, with a message, because a non-finite target makes the whole
batch loss NaN and so destroys every weight in one step. N is
therefore the number of usable rows, not nrow(df); the attributes
rows_kept (indices into df) and n_dropped record which.
df <- prepare_swrc_data(swrc_example, depth_col = "depth")
x <- c("clay", "silt", "bd_gcm3", "soc", "Depth_num")
sc <- fit_minmax(df, x)
m <- make_obs_matrices(df, x, sc, K = 16L)
dim(m$Xseq) # [N, K, p + 1]
range(m$pf) # normalised to [0, 1]
# swrc_example carries missing water contents by design, so some rows
# are dropped and N is smaller than nrow(df):
c(rows_in = nrow(df), rows_used = dim(m$Xseq)[1],
dropped = attr(m, "n_dropped"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.