Description Usage Arguments Value Examples
View source: R/gradient_descent.R View source: R/cv.gradient_descent.R
This function helps to conduct a k-fold cross-validation for the gradient descent method given model and data. The user need to specified input for the function gradient_descent. More details see gradient_descent.
Implement gradient descent for ordinary least square. Gradient descent can only handle design matrix with full rank. For design matrix with problem of collinearity, if perfect collinearity presents, the OLS estimate computed by gradient descent contains redundant estimate corresponding to variables should be omitted; For other cases with strong collinearity, the method may not be convergent (i.e. the lm_patho data). This function will pass the data to the the function "linear_model" when it cannot be able to handle the problem
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
formula |
A symbolic description of the model to be fitted. This should be a formula class argument. |
data |
Specification of a dataframe that contains the variables in the model. |
contrasts |
A list of contrasts. |
gamma |
Specification of a learning rate that adjust the OLS estimates along gradient. |
maxiter |
Maximum number of iterations for the updating process of OLS estimates. |
tolt |
A tolerance that bounds the difference between the current SSR and the updated SSR. |
... |
other inputs that need to be passed to the function ridge_regression. |
folds |
Number of folds used in the k-fold cross-validation |
a list containing the raw vector of residuals and the computed mean squared error (out of sample accuracy)
A list of component that imitates the output of lm() function. Including estimated coefficients for predictors specified in the formula. also may return a warning if the iterations exceed the maximum iteration number.
1 2 3 4 | data(iris)
cv.gradient_descent(Sepal.Length ~ ., iris)
data(iris)
gradient_descent(Sepal.Length ~ ., iris)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.