predict.osnnet: Predict New Examples Based on Observation Specific Neural...

Description Usage Arguments Details Value See Also Examples

View source: R/osnnet.R

Description

Predict new examples in conjunction with osnnet.

Usage

1
predict.osnnet(object, newdata, type = c("raw", "class"), ...)

Arguments

object

Object of class "osnnet".

newdata

A data.frame of cases to be classified or, if object has a formula, a data.frame with columns of the same names as the variables used. A vector will be interpreted as a row vector. If newdata is missing, an attempt will be made to retrieve the data used in osnnet.

type

Type of output.

...

Arguments passed to or from other methods.

Details

This function is a method for the generic function predict() for class "osnnet". It can be invoked by calling predict(x) for an object x of the appropriate class, or directly by calling predict.osnnet(x) regardless of the class of the object.

If the response in formula is a factor, appropriate classification networks are constructed; these have one output and entropy fit if the number of levels is two, and a number of outputs equal to the number of classes and a softmax output stage for more levels. If the response is not a factor, it is passed on unchanged to predict.osnnet.

Optimization is done via the BFGS method of optim.

Value

If type = "raw", the matrix of values returned by the trained network; if type = "class", the corresponding class (which is probably only useful if the net was generated by osnnet.formula).

See Also

osnnet, predict.nnet, nnet.

Other observation_specific nnet: osnnet

Examples

1
2
3
4
samp <- c(sample(1:50,25), sample(51:100,25), sample(101:150,25))
fit <- osnnet(Species ~ ., data = iris, subset = samp, size = 2, 
               rang = 0.1, maxit = 200, bw = 0.5, reps = 2)
pred <- predict(fit)

schiffner/locClass documentation built on May 29, 2019, 3:39 p.m.