fastRidgeRegression: Fast Ridge Regression with Training and Test Data

Description Usage Arguments Value Author(s) Examples

View source: R/LinearRegression.R

Description

Fast Ridge Regression with Training and Test Data, it will return the prediction result of the data X_test and the RMSE between Y_test and the prediction results.

Usage

1
fastRidgeRegression(X_train, Y_train, X_test, Y_test, training_part = 0.8)

Arguments

X_train

The data used for training the linear regression model, with only features.

Y_train

The data used for training the linear regression model, with only target.

X_test

The data used for prediction and computing RMSE, with only features.

Y_test

The data used for prediction and computing RMSE, with only target.

training_part

training_part is the ratio for training data.

Value

pred

The prediction for the test set the algorithm automatically splitted

RMSE

The RMSE between the prediction and true target result for the test set

Author(s)

Li (Richard) Liu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (X_train, Y_train, X_test, Y_test, training_part = 0.8)
{
    res_svd = svd(X_train)
    tuy = crossprod(res_svd$u, Y_train)
    beta = res_svd$v %*% (tuy * res_svd$d/(res_svd$d^2))
    pred = crossprod(t(X_test), beta)
    RMSE = eval_metrics(Y_test, pred)
    return(list(pred = pred, RMSE = RMSE))
  }

WeakCha/BIOSTAT625_HW4 documentation built on Dec. 18, 2021, 7:16 p.m.