Description Usage Arguments Value Examples
Performs the ridge linear regression model.
1 | ridge_regression(X_train, Y_train, X_test, lambda)
|
X_train |
A Matrix of trainning observations. |
Y_train |
A numeric vector of classes or values of the trainning observations. |
X_test |
A Matrix of testing observations. |
lambda |
The penalty parameter. |
predicted values
1 2 3 4 5 6 7 8 9 10 11 | X <- as.matrix(cbind(runif(n = 100), runif(n = 100)))
Y <- 3*X[, 1] - 2.5*X[, 2] + 0.2 * runif(100)
pos <- sample(100, 70)
X_train <- X[pos, ]
X_test <- X[-pos, ]
Y_train <- Y[pos]
Y_test <- Y[-pos]
lambda <- 0.25
Y_predicted <- ridge_regression(X_train = X_train, Y_train = Y_train, X_test = X_test, lambda = lambda)
plot(x = (1:100)[-pos], y = Y_test, col = 'red')
points(x = (1:100)[-pos], y = Y_predicted, col = 'blue')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.