Description Usage Arguments Value Author(s) Examples
View source: R/LinearRegression.R
This function will do a linear regression like a machine learning taste, which means it will split the dataset into training set (with the ratio training_part) and test set and return the predicted result and the RMSE of the test set.
1 | LinearRegression(data, training_part = 0.8, features = NULL, target, seed = 200)
|
data |
|
training_part |
|
features |
|
target |
|
seed |
|
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 |
Li (Richard) Liu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ##---- 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 (data, training_part = 0.8, features = NULL, target,
seed = 200)
{
set.seed(seed)
res = dataPreprocess(data, features, target, training_part)
X_train = res$X_train
X_test = res$X_test
Y_train = res$Y_train
Y_test = res$Y_test
Y_train = as.matrix(Y_train)
Y_test = as.matrix(Y_test)
res = fastRidgeRegression(X_train, Y_train, X_test, Y_test,
training_part)
beta = res$beta
pred = res$pred
RMSE = res$RMSE
return(list(pred = pred, RMSE = RMSE))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.