predict.bnns | R Documentation |
"bnns"
ObjectsGenerates predictions from a fitted Bayesian Neural Network (BNN) model.
## S3 method for class 'bnns'
predict(object, newdata = NULL, ...)
object |
An object of class |
newdata |
A matrix or data frame of new input data for which predictions are required. If |
... |
Additional arguments (currently not used). |
This function uses the posterior distribution from the Stan model in the bnns
object to compute predictions for the provided input data.
A matrix/array of predicted values(regression)/probabilities(classification) where first dimension corresponds to the rows of newdata
or the training data if newdata
is NULL
. Second dimension corresponds to the number of posterior samples. In case of out_act_fn = 3
, the third dimension corresponds to the class.
bnns
, print.bnns
# Example usage:
data <- data.frame(x1 = runif(10), x2 = runif(10), y = rnorm(10))
model <- bnns(y ~ -1 + x1 + x2,
data = data, L = 1, nodes = 2, act_fn = 2,
iter = 1e1, warmup = 5, chains = 1
)
new_data <- data.frame(x1 = runif(5), x2 = runif(5))
predictions <- predict(model, newdata = new_data)
print(predictions)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.