Multivariate Linear Regression code

조회 수: 2 (최근 30일)
b
b 2012년 5월 18일
In my hand, 30 samples of 4 features and 30 outputs. i want to learn the regression equation of these as;
theta=theta(0) + theta(1) x(1)+ ... + theta(4) x(4)
I am using gradient descent algorithm for this regression analysis. there are three main equations;
for m=1:30;
cost function= J(theta(0)..,theta(4))=1/2m * sum(h(theta)x - y) ^2
%sum is from 1 to m. x and y are from 1 to m.
theta(j) := theta(j) - alpha (derivative/derivative theta(j)) J(theta(j)
Thanks
  댓글 수: 1
b
b 2012년 5월 18일
Sorry for that, i have 30 samples of 3 features output also.
input=30x4 matrix
output=30x3 matrix

댓글을 달려면 로그인하십시오.

답변 (2개)

b
b 2012년 5월 18일
If there is a chance of doing this with 3 features output, it will be superb. otherwise, it's also OK.

bym
bym 2012년 5월 18일
I really do not understand your question, but perhaps this is what you are looking for:
x = rand(30,4);
>> y = rand(30,1);
>> X = [ones(30,1) x];
>> theta = X\y
theta =
0.6702
0.1183
-0.4163
-0.1072
-0.1355
  댓글 수: 1
b
b 2012년 5월 18일
Actually, no. I have x and y values and theta values will be obtained from the equation.
I want the cost function code.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Linear Regression에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by