Description Usage Arguments Details Value See Also Examples
Predict new examples using a trained neural network.
1 2 |
object |
an object of class ‘ann’ as returned by function |
newdata |
matrix, data frame or vector of input data.
A vector is considered to comprise examples of a single input or
predictor variable. If |
derivs |
logical; should derivatives of hidden and output nodes be
returned? Default is |
... |
additional arguments affecting the predictions produced (not currently used). |
This function is a method for the generic function predict()
for class ‘ann’. It can be invoked by calling predict(x)
for an
object x
of class ‘ann’.
predict.ann
produces predicted values, obtained by evaluating the
‘ann’ model given newdata
, which contains the inputs to be used
for prediction. If newdata
is omitted, the
predictions are based on the data used for the fit.
Derivatives may be returned for sensitivity analyses, for example.
if derivs = FALSE
, a vector of predictions is returned.
Otherwise, a list with the following components is returned:
values |
matrix of values returned by the trained ANN. |
derivs |
matrix of derivatives of hidden (columns |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ## fit 1-hidden node `ann' model to ar9 data
data("ar9")
samp <- sample(1:1000, 200)
y <- ar9[samp, ncol(ar9)]
x <- ar9[samp, -ncol(ar9)]
x <- x[, c(1,4,9)]
fit <- ann(x, y, size = 1, act_hid = "tanh", act_out = "linear", rang = 0.1)
## get model predictions based on a new sample of ar9 data.
samp <- sample(1:1000, 200)
y <- ar9[samp, ncol(ar9)]
x <- ar9[samp, -ncol(ar9)]
x <- x[, c(1,4,9)]
sim <- predict(fit, newdata = x)
## if derivatives are required...
tmp <- predict(fit, newdata = x, derivs = TRUE)
sim <- tmp$values
derivs <- tmp$derivs
|
initial value 654.714580
iter 20 value 211.297508
iter 40 value 180.076757
iter 60 value 179.466959
iter 80 value 179.346948
final value 179.346752
converged
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.