Last chance! 50% off unlimited learning
Sale ends in
predict.foba(object, newx, k, type=c("fit","coefficients"),...)
Tong Zhang (2008) "Adaptive Forward-Backward Greedy Algorithm for Sparse Learning with Linear Models", NIPS'08 (short version).
data(boston)
model <- foba(boston$x,boston$y,s=20,nu=0.9)
### make predictions at the values in x, at sparsity level 5
py <- predict(model, boston$x, k=5, type="fit")
print(paste("mean squared error =", mean((py$fit-boston$y)^2)))
### extract the coefficient vector at sparsity level 5
coef <- predict(model, k=5, type="coef")
print("top five variables:")
coef$selected.variables
Run the code above in your browser using DataLab