ridge()

Read(1573) Label: model, prediction,

Description:

Build models and perform predictions using the ridge regression method.

Syntax:

ridge(X, Y, learning_rate, iterations)

The function fits together matrix X and vector Y using the ridge regression method and returns model information that includes coefficient matrix and and intercept. The model information can act as parameter F in ridge(X’, F) to perform a fitting computation

ridge(X’, F) 

The function fits together two matices that have same number of columns – that is, perform predicitions on another matrix X’ using model F, and returns a vector

Parameter:

X

A matrix

Y

A vector having the same number of rows as matrix X

learning_rate

Learning rate that is a decimal between 0 and 1; default value is 0.01

iterations

Number of iterations; default is 1000

X’

A matrix that has same number of columns as matrix X

F

The return result of ridge(X, Y, learning_rate, iterations)

Return value:

A matrix or a vector

Example:

 

A

 

1

[[1.1,1.1],[1.4,1.5],[1.7,1.8],[1.7,1.7],[1.8,1.9],[1.8,1.8],[1.9,1.8],[2.0,2.1],[2.3,2.4],[2.4,2.5]]

 

2

[16.3,16.8,19.2,18,19.5,20.9,21.1,20.9,20.3,22]

 

3

=ridge(A1,A2,0.01,10000)

 

 

 

Fit A1 and A2 together using ridge regression method and return coefficient matrix A3(1) and intercept A3(2) .

4

=ridge(A1,A3)

 

 

 

Perform prediction on A1 using model A3; the result can be compared with actual values in A2.