octave - Vectorization or sum as matrix operations -


let there following definition of gradient descent cost function

enter image description here

with hypothesis function defined as

enter image description here

what i've come multivariate linear regression is

theta = theta - alpha * 1/m * ([theta', -1]*[x';y']*x)'; h_theta = 1/(2*m)* (x*theta - y)'*(x*theta-y); 

(octave notation, ' means matrix transpose, [a, n] means adding new column matrix scalar value n, [a; b] means appending matrix b matrix row-wise)

it's doing job correctly how far can tell (the plots ok), have strong feeling it's unnecessarily complicated.

how write little matrix operations possible (and no element-wise operations, of course)?

i don't think unnecessarily complicated, , instead want. matrix operations because don't have loop on elements or element-wise operations. remember taking course online , solution seems pretty similar.


Comments