loss | R Documentation |
Compute the loss function needed for prediction error estimation.
loss(p, y, method = "log", ...)
p |
A vector of predicted outcome values. |
y |
A vector of observed outcome values. |
method |
Loss function definition. One between "log" (default) and "sqerror". |
... |
Currently ignored. |
The subject-level prediction error, calculated through the
topsim
function, is strongly correlated
with the loss function values. However, while the former can be
only calculated for the entire training set, the latter can be
computed for the new input profile(s). Therefore, the prediction
error (E) for the input is calculated as:
E = b0 + b*L, where L is the loss function value.
L can be currently defined as either "log":
L = -1*(y*log(p) + (1 - y)*log(1 - p)) (default), or
"sqerror": L = (p - y)^2.
Additionally, the cost is calculated as either average loss sum(L)/n
or root mean squared error sqrt(sum(L)/n), for "log" and "sqerror",
respectively.
A list of 2 objects:
"loss", loss function values;
"cost", cost function value.
Fernando Palluzzi fernando.palluzzi@gmail.com
us.predict
,
brier
# RBM prediction vs. reality over the simulated dataset p <- predict(mpm.rbm$fit, dichotomize(mpm.us[2:15], asFactor = TRUE), type = "response") L <- loss(p, mpm.us$y) print(quantile(L$loss)) print(L$cost) # Overall RBM performances y.hat <- ifelse(p > 0.5, 1, 0) P <- performance(obs = mpm.us$y, pred = y.hat) print(P)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.