Description Usage Arguments Value Note See Also Examples
View source: R/fuzzy_forest_obj.R
Predict method for fuzzy_forest object. Obtains predictions from fuzzy forest algorithm.
1 2 |
object |
A fuzzy_forest object. |
new_data |
A matrix or data.frame containing new_data. Pay close attention to ensure feature names match between training set and test set data.frame. |
... |
Additional arguments not in use. |
A vector of predictions
This work was partially funded by NSF IIS 1251151 and AMFAR 8721SC.
ff
,
wff
,
ff.formula
,
wff.formula
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | library(mvtnorm)
gen_mod <- function(n, p, corr) {
sigma <- matrix(corr, nrow=p, ncol=p)
diag(sigma) <- 1
X <- rmvnorm(n, sigma=sigma)
return(X)
}
gen_X <- function(n, mod_sizes, corr){
m <- length(mod_sizes)
X_list <- vector("list", length = m)
for(i in 1:m){
X_list[[i]] <- gen_mod(n, mod_sizes[i], corr[i])
}
X <- do.call("cbind", X_list)
return(X)
}
err_sd <- .5
n <- 500
mod_sizes <- rep(25, 4)
corr <- rep(.8, 4)
X <- gen_X(n, mod_sizes, corr)
beta <- rep(0, 100)
beta[c(1:4, 76:79)] <- 5
y <- X%*%beta + rnorm(n, sd=err_sd)
X <- as.data.frame(X)
Xtest <- gen_X(n, mod_sizes, corr)
ytest <- Xtest%*%beta + rnorm(n, sd=err_sd)
Xtest <- as.data.frame(Xtest)
cdist <- as.dist(1 - cor(X))
hclust_fit <- hclust(cdist, method="ward.D")
groups <- cutree(hclust_fit, k=4)
screen_c <- screen_control(keep_fraction = .25,
ntree_factor = 1,
min_ntree = 250)
select_c <- select_control(number_selected = 10,
ntree_factor = 1,
min_ntree = 250)
ff_fit <- ff(X, y, module_membership = groups,
screen_params = screen_c,
select_params = select_c,
final_ntree = 250)
#extract variable importance rankings
vims <- ff_fit$feature_list
#plot results
modplot(ff_fit)
#obtain predicted values for a new test set
preds <- predict(ff_fit, new_data=Xtest)
#estimate test set error
test_err <- sqrt(sum((ytest - preds)^2)/n)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.