Handson-ml: chapture 8 ploting projection

Created on 7 Jul 2018  路  5Comments  路  Source: ageron/handson-ml

i'm having trouble understanding following code of chapter 8 ploting projection and plane of jupyter notebook cell 23 and 24 code :

R = C.T.dot(C)
z = (R[0, 2] * x1 + R[1, 2] * x2) / (1 - R[2, 2])

can u please explain it to me.

Most helpful comment

Aha, yes, it took me a while to figure that one out. I don't have the time right now (off to Singapore tomorrow), but I'll try to remember how I found this. I suppose it's not urgent? :)

All 5 comments

Aha, yes, it took me a while to figure that one out. I don't have the time right now (off to Singapore tomorrow), but I'll try to remember how I found this. I suppose it's not urgent? :)

Was there any solution to this? I'm running into the same question.. I thought the plane equation would be found with the first two eigenvectors cross product - or the third eigenvector. But I still don't understand where the "1-" came from
The figure below shows two planes - the grey is plotted with the books method, and the green is plotted with the third principle component/orthogonal vector.
So I realized that using z2 = (Vt.T[0,2] *_x1 + Vt.T[1,2] *_x2)/(-Vt.T[2,2]) is the same as using the books method - the difference being the "1-".. I still don't understand why the books method works. Ill update if I find the answer
Questions

Hi @johnvorsten ,
Thanks for your question.
SVD gives us U, 危 and V such that U @ 危 @ V.T = X (centered), where @ is matrix multiplication, and V.T is the transpose of V.
Let us define C = V.T[:2].
To project X from 3D down to 2D, we must multiply it by C.T.
To project the dataset back from 2D up to 3D, we must multiply it by C.
If we project the dataset from 3D down to 2D and then back to 3D, we get the 3D coordinates of the projections of all the original points onto the 2D plane in 3D space.
If we define R = C.T @ C then multiplying the original 3D dataset by R will just chain both operations and give use the coordinates of the projection onto the plane in 3D space.

Okay, now the points on that plane are the only ones that do not change when projected down to 2D and back to 3D. So if we have a matrix P=[[x1, x2, z]] containing a single instance with 3D coordinates x1, x2 and z, then P @ R just returns P. So if we look into what exactly is calculated when we compute P @ R, we get:

(P @ R)[0,0] = x1 * R[0, 0] + x2 * R[0, 1] + z * R[0, 2] = x1
(P @ R)[0,1] = x1 * R[1, 0] + x2 * R[1, 1] + z * R[1, 2] = x2
(P @ R)[0,2] = x1 * R[2, 0] + x2 * R[2, 1] + z * R[2, 2] = z

Looking at the last line, you can see that you can turn it into:
x1 * R[2, 0] + x2 * R[2, 1] = z - z * R[2, 2]

Then factor out z:
x1 * R[2, 0] + x2 * R[2, 1] = z * (1 - R[2, 2])

And divide both sides by (1 - R[2, 2]):
(x1 * R[2, 0] + x2 * R[2, 1]) / (1 - R[2, 2]) = z

And that's how the 1 - R[2,2] appears.
Hope this helps.

That makes a lot of sense - it is just he projection of the first two dimensions onto the planes basis if I understand correctly. Thanks!

Closing stale issues. Please reopen if you are still experiencing a problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

batblah picture batblah  路  5Comments

kenorb picture kenorb  路  3Comments

tetsuyasu picture tetsuyasu  路  3Comments

qinhanmin2014 picture qinhanmin2014  路  5Comments

WillKoehrsen picture WillKoehrsen  路  4Comments