predict

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

predict

Tomi Piriyev
hi,

"
if sigmoid(theta'*x) >= 0.5, p =1
else p=0
"
i tried to use this code, , but compiler gets "error: operator *: nonconformant arguments (op1 is 1x3, op2 is 100x3)"

could you help me


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: predict

Kimmo Luoma
Hi!

Im not sure what arguments sigmoid accepts but
multiplication works if you replace x*theta with theta*x or
x'*theta'.
The result is that in first you get size(theta*x)=[300,3]
and in second size(x'*theta')=[3,300].
Hope this helps.

Kimmo

On Tue, 2011-11-15 at 22:50 +0200, Tomi Piriyev wrote:

> hi,
>
> "
> if sigmoid(theta'*x) >= 0.5, p =1
> else p=0
> "
> i tried to use this code, , but compiler gets "error: operator *:
> nonconformant arguments (op1 is 1x3, op2 is 100x3)"
>
>
> could you help me
>
>
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: predict

Georgios Kousiouris
In reply to this post by Tomi Piriyev

hi,

in matrix multiplication the inner dimensions must be identical. thus when you multiply an AxB matrix with a CxD one, you must have that B=C. and the result is a AxD matrix

BR,
George


On 11/15/2011 10:50 PM, Tomi Piriyev wrote:
hi,

"
if sigmoid(theta'*x) >= 0.5, p =1
else p=0
"
i tried to use this code, , but compiler gets "error: operator *: nonconformant arguments (op1 is 1x3, op2 is 100x3)"

could you help me



_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave


-- 



_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: predict

Juan Pablo Carbajal
On Wed, Nov 16, 2011 at 8:08 AM, George Kousiouris
<[hidden email]> wrote:

>
> hi,
>
> in matrix multiplication the inner dimensions must be identical. thus when
> you multiply an AxB matrix with a CxD one, you must have that B=C. and the
> result is a AxD matrix
>
> BR,
> George
>
>
> On 11/15/2011 10:50 PM, Tomi Piriyev wrote:
>
> hi,
> "
> if sigmoid(theta'*x) >= 0.5, p =1
> else p=0
> "
> i tried to use this code, , but compiler gets "error: operator *:
> nonconformant arguments (op1 is 1x3, op2 is 100x3)"
> could you help me
>
>
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave
>
>
> --
>
>
>
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave
>
>

Note that if the result of sigmoid is a matrix as well, you should put
p to one in the right places. That is

X = theta*x.';
[n m] = size(X);
p = false(n,m);
ind = sigmoid(X) >= 0.5;
p(ind) = true;


--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Z├╝rich
http://ailab.ifi.uzh.ch/carbajal/
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: predict

pathematica
Denoting the matrix that follows from applying your custom sigmoid function to the matrix product (suitably debugged for conformity) by A, I think the following will achieve your goal (brackets not required; included for clarity):

p = (A >= 0.5);

so, your custom predict function (with appropriate transpositions to achieve conformity for the matrix product in the sigmoid function) might be written in one line as (outer brackets included for clarity):

p = ( sigmoid(theta' * x') >= 0.5 );
However good you think Octave is, it's much, much better.