Predict method for the nn function

# S3 method for nn
predict(
  object,
  pred_data = NULL,
  pred_cmd = "",
  dec = 3,
  envir = parent.frame(),
  ...
)

Arguments

object

Return value from nn

pred_data

Provide the dataframe to generate predictions (e.g., diamonds). The dataset must contain all columns used in the estimation

pred_cmd

Generate predictions using a command. For example, `pclass = levels(pclass)` would produce predictions for the different levels of factor `pclass`. To add another variable, create a vector of prediction strings, (e.g., c('pclass = levels(pclass)', 'age = seq(0,100,20)')

dec

Number of decimals to show

envir

Environment to extract data from

...

further arguments passed to or from other methods

Details

See https://radiant-rstats.github.io/docs/model/nn.html for an example in Radiant

See also

nn to generate the result

summary.nn to summarize results

Examples

result <- nn(titanic, "survived", c("pclass", "sex"), lev = "Yes") predict(result, pred_cmd = "pclass = levels(pclass)")
#> Neural Network #> Data : titanic #> Response variable : survived #> Level(s) : Yes in survived #> Explanatory variables: pclass, sex #> Prediction command : pclass = levels(pclass) #> #> sex pclass Prediction #> male 1st 0.336 #> male 2nd 0.220 #> male 3rd 0.159
result <- nn(diamonds, "price", "carat:color", type = "regression") predict(result, pred_cmd = "carat = 1:3")
#> Neural Network #> Data : diamonds #> Response variable : price #> Explanatory variables: carat, clarity, cut, color #> Prediction command : carat = 1:3 #> #> clarity cut color carat Prediction #> SI1 Ideal G 1 4987.183 #> SI1 Ideal G 2 15496.837 #> SI1 Ideal G 3 18541.164
predict(result, pred_data = diamonds) %>% head()
#> Neural Network #> Data : diamonds #> Response variable : price #> Explanatory variables: carat, clarity, cut, color #> Prediction dataset : diamonds #> #> carat clarity cut color Prediction #> 0.320 VS1 Ideal H 570.442 #> 0.340 SI1 Very Good G 354.859 #> 0.300 VS2 Very Good G 493.759 #> 0.350 VVS2 Ideal H 999.885 #> 0.400 VS2 Premium F 1080.257 #> 0.600 VVS1 Ideal E 3524.251