iqnn_predict: Predict for test data using iqnn model

Description Usage Arguments Value See Also Examples

View source: R/IterativeQuantileNearestNeighbors.R

Description

Predict the response value for test data using iqnn model defined using training data from the iqnn function

Usage

1
iqnn_predict(iqnn_mod, test_data, type = "estimate", strict = FALSE)

Arguments

iqnn_mod

iterative quantile nearest neighbors model generated by the iqnn function

test_data

Data frame of test data to estimate response values for

type

output "estimate", "binsize", or "both"

strict

TRUE/FALSE: If TRUE Observations must fall within existing bins to be assigned; if FALSE the outer bins in each dimension are unbounded to allow outlying values to be assigned.

Value

predicted responses, number of neighbors or both

See Also

Other iterative quantile nearest-neighbors functions: iqnn_cv_predict, iqnn_tune, iqnn

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Test Regression
test_index <- c(1,2,51,52,101,102)
iqnn_mod <- iqnn(data=iris[-test_index,], y="Petal.Length",
                 bin_cols=c("Sepal.Length","Sepal.Width","Petal.Width"), 
                 nbins=c(3,5,2), jit=rep(0.001,3), stretch=TRUE, tol=rep(.001,3))
test_data <- iris[test_index,]
iqnn_predict(iqnn_mod, test_data,strict=FALSE)
iqnn_predict(iqnn_mod, test_data,strict=TRUE)
iqnn_predict(iqnn_mod, test_data,type="both")

# Test Classifier
iqnn_mod <- iqnn(data=iris[-test_index,], y="Species", mod_type="class", 
                 bin_cols=c("Sepal.Length","Sepal.Width","Petal.Width"), 
                 nbins=c(3,5,2), jit=rep(0.001,3))
test_data <- iris[test_index,]
iqnn_predict(iqnn_mod, test_data,strict=TRUE)
iqnn_predict(iqnn_mod, test_data,type="both",strict=FALSE)

kmaurer/iqbin documentation built on Jan. 1, 2020, 6:48 p.m.