Search code examples
machine-learningoctavelogistic-regression

Writing sigmoid function with input as (X * theta)


In Machine learning course, I am unable to visualize below input.

we have below equation in Logistic Regression :

enter image description here

We can write it in octave as below in sigmoid.m:

g = (1 ./ ( 1 + e.^(-z)));

Now, to calculate costFUnction.m, we are getting probability as:

h = sigmoid(X*theta);

From, the above picture, shouldn't it be:

h = sigmoid(theta'*X);

What am I missing here. I am newbie to ML so forgive me if I am missing something here.


Solution

  • If you'll refer to the material shared here, you can see that

    enter image description here

    and what we want from h(x) is:

    enter image description here

    enter image description here

    to visualize it:

    X =  [ 1 x1 ; 1 x2 ; 1 x3;]
    theta = [ t0 t1;]
    X * theta
    % will give  [ t0+(x1*t1) ; t0+(x2*t1) ; t0+(x3*t1) ; ] 
    

    where each row of above matrices represent separate hypothesis.