Description Usage Arguments Value Note Examples
View source: R/predictive_modeling.R
This function trains a Elastic Net regressor using the training data
provided and predict response for the test features. This implementation
depends on the glmnet
package.
1 2 3 4 5 6 7 8 9 10 11 |
x_train |
Training features for designing the EN regressor. |
y_train |
Training response for designing the EN regressor. |
x_test |
Test features for which response values are to be predicted.
If |
lims |
Vector providing the range of the response values for modeling. If missing, these values are estimated from the training response. |
optimize |
Flag for model tuning. If |
alpha |
EN mixing parameter with 0 ≤ α ≤ 1. |
seed |
Seed for random number generator (for reproducible outcomes).
Defaults to |
verbose |
Flag for printing the tuning progress when |
parallel |
Flag for allowing parallel processing when performing grid
search i.e., |
If x_test
is missing, the trained EN regressor.
If x_test
is provided, the predicted values using the model.
The response values are filtered to be bound by range in lims
.
1 2 3 4 5 6 7 8 9 10 11 | set.seed(86420)
x <- matrix(rnorm(3000, 0.2, 1.2), ncol = 3); colnames(x) <- paste0("x", 1:3)
y <- 0.3*x[, 1] + 0.1*x[, 2] - x[, 3] + rnorm(1000, 0, 0.05)
## Get the model only...
model <- EN_predict(x_train = x[1:800, ], y_train = y[1:800], alpha = 0.6)
## Get predictive performance...
y_pred <- EN_predict(x_train = x[1:800, ], y_train = y[1:800], x_test = x[801:1000, ])
y_test <- y[801:1000]
print(performance(y_test, y_pred, measures = "RSQ"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.