Description Usage Arguments Value Examples
View source: R/base_functions.R
Fit conformal prediction bands based on density estimation for regression
1 2 3 4 5 6 7 8 9 10 |
x |
Matrix with covariates of training set |
y |
Vector with the (continuous) responses of training set |
per_train |
# percentage of samples used for traning density estimator (defaults to 40%) |
per_val |
# percentage of samples used for tuning density estimator (defaults to 10%) |
per_ths |
# percentage of samples used for computeing thresholds for the conformal method (defaults to 50%) |
k |
# Number of clusters for cd-split. Default to round(per_ths*nrow(as.matrix(x))/100) so that each cluster has on average 100 samples |
regressionFunction |
# regression function to be used for FlexCode. Defaults to Random Forests. See FlexCode documentation for additional regression methods. |
... |
Additional arguments to FlexCoDE::fitFlexCoDE |
Returns an object of the class predictionBands with the following components:
density_fit |
Object of the class FlexCoDE with the estimated density |
cum_dist_evaluated_train |
Cumulative conditional distribution functions on the training set (for dist-split) |
conformity_score_train |
Conformal scores on the training set (for cd-split) |
t_grid |
Level sets of the densities |
g_train |
Profiles of the training sample |
center_kmeans |
The center of the clusters found by kmeans (in the profile space) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # generate data
n <- 1000
n_new <- 50
d <- 10
data <- matrix(NA,n,d+1)
x <- matrix(rnorm(n*d),n,d)
y <- x[,1]+rnorm(n,0,0.1)
fit <- fit_predictionBands(x,y,0.5,0.4,0.1)
xnew <- matrix(rnorm(n_new*d),n_new,d)
ynew <- xnew[,1]+rnorm(n_new,0,0.1)
# Dist-split
bands <- predict(fit,xnew,type="dist")
bands[[1]]
bands[[2]]
plot(bands)
plot(bands,ynew)
# CD-split
bands <- predict(fit,xnew,type="cd")
bands[[1]]
bands[[2]]
plot(bands)
plot(bands,ynew)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.