Description Usage Arguments Examples
View source: R/cv-gradient-descent.r
This is a function fitting the OLS model using gradient descent that calculates the penalty based on the out-of-sample accuracy. Here we use cross validation to calculate the out-of-sample accracy.
1 2 3 4 5 6 7 8 9 10 | gradient_descent_OLS_cv(
formula,
data_frame,
nfolds = 10,
contrasts = NULL,
lambda = 1e-04,
tolerence = 1e-20,
beta1 = 1,
max_itr = 1e+06
)
|
formula |
a formula of linear model |
data_frame |
a data_frame |
nfolds |
Default is 10. the number of folds for cross validation |
contrasts |
Default is NULL. a list of constasts for factor variables |
lambda |
Default is 0.0001. The speed of gradient descent |
tolerence |
Default is 1e-20. The minimum difference between the old ssr and the update ssr. |
beta1 |
Default is 1. The initial value of beta. |
max_itr |
Default is 1e6. The maximum number of iterations |
1 2 | data(iris)
gradient_descent_OLS_cv(Sepal.Length ~ ., iris,nfolds=10)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.