Dump output of fluid.pca~ doesn't return bases

Trying to build the thing that @tedmoore suggests in this thread, and when trying to get the bases out of fluid.pca~ I realized I can’t actually access them in Max. Instead I only get <atomarray-object> for each entry.

If I dump the .json file out and open it in a text editor I can see the bases looking something like this:

"bases": [
    [
      -0.20580618747400992,
      -0.4272234897414199,
      0.06683704032516632,
      -0.3502434755871455,
      0.027358465228359895,
      0.3442595806923155,
      0.08456370551625703,
      0.009403553085187987,
      0.14416272018511142,
      -0.006708498415139461,
      -0.02560733094762434,
      0.7071067811865477
    ], (etc...)

So they are “there”.

Here’s a patch showing what I mean.


----------begin_max5_patcher----------
2604.3oc6bs0iiaaE94Y9UvZjmJl0U7htETTr4gBz9P6KaA5CAECnknmQYkk
TEomclDj42d3MYKYK4Qdrn7hj0AwdMor347cten37K2dyhUkOy3K.eO3GA2b
yub6M2nGRMvM1ueyhMzmSxob8ksHobyFVgXwcl4DrmE5wwKA+UpnbCstl9xG
JW8SrDweCrtrFjReg+mZt97rBVR41B8OBYGrX6lxshblPuDd1QWWVHVSSXpw
f1wxR0Kl71+Ar2hVWHO6m0WHxaY6eeAcid3E+CV9SLQVBcw90LqnYIat8UTQ
xiYEObesj5MnB1OTdGA9w5OPD08GPBV5A9epeyud6sp2tajnWA6KRZ+HvqBv
EaWudwIwiV7NJpW1vaX1ffUzMNT9QbHzKH19hHYFhlyvJVp8MfUaYDKmHQzr
b1SrZdVYQKT6lEzppVCeSqehh8+oR8MJ5tcCkUXFBtanZ1SY6tsd6FlVK4Cg
jI1VaDiOGPVr+9TlxpK1lo+QlAkRBKMowbk3mWY0gzhllo2iLZAp9s.qvMxa
OTHEnOjWl7YVZK.9lEkUrhrhpZFWZKPEVJe2zor0zs4h6aqYBQK6c9FU7dmb
m96OTmQy2Q8OTmkVVnHhNxA0vMK2OBf9JtQ89dlQeEEzpd9wFS1AljKYxs7U
zZkXZUNqk0qTMtrLu6T69c4r0B6zUYEEGfhhxpgmrN6gGOwucUobxMm5dqmg
e+1Byr2KUHD2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BRMe+PiwB0pAzHnAcItVcXq0Eprf.iU
68bohfQRDJohyHBR7Hoh.WRDvQRDDWJOTMTabTAzgTAdrBjdH2MYlGhZqYhJ
AP3QsWxbd370O8n5u3JFIZxXjPrtMYcajyrwGJMe3H3CrKUNwi0agpZZE45F
pverTgKcWfIikJhbIUn7BfFSPDWRDi0mUijycTwXLQPtLTFbrdNwtThnt23Q
FOEdRu21GxTehdu5i2+MGR4mi+ZmQDvw5lykDwXrrwCiD+N4uJ.m7nGwEzhT
ZcprnxWOyCbTdFW71G3nfY5z8ghi647FAc3o1pJg9pta.oYxZhTmSFN.4DLD
6bLzdzRIAjkjXbreSiyQPIHZ2nMGbVl6df2tCzyYaVMQe+oS5hNKgwN+nDZU
JC64jcgQd8hmZBsaIxF38PWeVP9XWdvNo1MT7a7dGdGIIG6RgfiXk1QOWzRg
a6HeHdBNE7j2H3oo.7hGiXhLEXW7HVnfIXcBmIjKXD5BPxDrPjQYIENAqj1F
A9FqTr+TsRuEOEOUKDZjfm8hNHwYDFoyXV9Q3g9OCs+Ud4notTxlLB7YRD43
w377XQtI.wAGqW0hbvw48fixaOGi2gOBuGd7c0I+Nzw181e81eCvNgr+L
-----------end_max5_patcher-----------

They’re a nested JSON array, and Max dicts unfortunately go screwy with nested JSON arrays (presumably because there’s no such thing as a nested list to convert them to), so one has to resort to JS to get it out (see my forthcoming video for doing the same thing with KMeans).

This function will take a dictionary, and use the first argument given to the js object as the key containing 2D data to extract (i.e. values in the case of PCA), and put the numbers into a jit.matrix. YMMV.

inlets = 1; 

function dictionary(n)
{	
	var key = jsarguments[1]; 	
	var d = new Dict(n);  	
	var j = JSON.parse(d.stringify());	
	var m = j[key]; 
	k = m.length; 
	dim = m[0].length; 
		
	var res = new JitterMatrix(1,"float32",k,dim);	
	for(i  = 0; i < k; i++)
		for(j = 0; j < dim; j++)
			res.setcell2d(i,j,m[i][j]); 
	
	outlet(0,"jit_matrix",res.name);	
}
2 Likes

Hmm, that’s unfortunate.

I guess this is a “Max dict” problem, but presumably something like that can render as a Max array (i.e. “a list”)?

You’ll have to appologize my js/jit. noobness, but I’m not entirely sure how to implement this in a patch.

Also, wouldn’t it be bases that I’m after? Or is values in this sense mean key/value pairs for the dict structure?


----------begin_max5_patcher----------
2773.3oc6bsziiiaD9r6eEDF6ofdb3C8Lml8P.RNjbYBPNrXgAsDc2ZFYIEQ
5d5dWryu8vGR1R1RpksEkGjL8focaQYwp9ph0Kxx+9CKVtI+UFeI3u.9EvhE
+9CKVnuj5BKpd+hk6nuFkR45aa4mSDqhXooaRyi9xxGM2Q19c46EoLg9dbpt
517LwVZDScMX00hxS02CBWcAymS7VAyPEKSS3hkOBVd3+fes5VSh0TP9lO+A
h2xFSBO42zeZDYU87Tl+Uy7z31xn6z21xetLgl1f1SxpI8ZppfJhdNI6o0kr
HggvbCbjOcfquu5EhKT8BBGtBB9U0G5Od3A0udbj33NFmSehUSEB1qhZ7c8N
pnL4UvdBI.BCCQntwYTePX2Pl6kxwXbvJ2GAdXWCq5odAiuRFdydgHO6B4jM
zrm5laHKOP3kR4pfUtlkQ2j1RaqEmhFP1BUZN.GGsrE6T+6qhQyXeURgcIXW
MRAauqMNpbz+JC7xqi4cQgFwL9lDyCv8IRgT2LLoWM4gLBf7uVV0rF1AZCNs
.vE62tsaFEdNWfC5jKf8yE9FkUEuD5ifdgU+3nzfOxRMe.Rf2vHUbhzfXRJ6
EVIOQtl7HnsXIsnnwkWz3inX+OmqePAOd3RIYlKgNboR1KIGdrvCWlVJ4Cgj
I1WZrB+pmyxiOm7XVY19D8GxbQojnhlzXtx5MunxchVzTO7QjAQzJuHnVU1y
HfcBfGgCoP8IkmKVbCPVp3UvxRxJJYbVlfJpn9CCGy1R2mJV2xYCdUmiehGu
1C1oKnEKepLINOSQDsjEpKWOcRlyXF1sIynuiLZQGeXotkDW5YPtjI2y2PKU
hpJil35AE44osG5vmKksUTMbQRV1InnHun+AKSd54A9raxkCtanmsdD958Yl
QWKUJDq4zWZi1BZZZ0Jy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IBGaJObfikJPVjJHiUfzA4tKwbHp40m4
eecpLsKujogpb0mdT8arEiDLYLhOQWlr1ExY13CklOZD7AwlJmjwZsPkMshb
sCU3NVpvllKHNikJBrIUnrBfGiSDaRDi0lUsjydTwXVhfsoqLzXsbRroDQ8r
IizeJZPq2UGxTWG8d0Gd7cVjxuD60ViHPi0LmMIhwrxl7+7sU9fsdDWPyhok
wxjJ+1E1vQ0eGCNbCG4MSc2GAG1Q+FgrXWaUDQ+ltZ.wIxbhT8ICGfsBFRrN
FV2GtgNqbBIgt0ENGijfX0FsQl9dYtcCu8HnidaVMPWe6+bS8RHxy58RXkVI
riV6hfg1Pq7y5JUsV0A7qj+8Kzz8L9jfVWp1Tcm9a9FBDg8O66SuQZJU0ZaG
DCMXtC1G6rMYO2ToddaW8ACPepWkJ397niZ8sTx6DvbM3VFaZVOXmx3IcpUe
KN10TitsolLFtFezA5UOSnwLQtGyJ5pmH7XlIzDvQjlwezWnzSwDggiA6lfI
JzcDSji6TnM3MhYxaBlH+YB57Fgx.xYBlHmwHiv9SgLxsYT98U1S2oZld2kr
dS0LgGI5UcSmjwG1CqS0S9h+YQiBMe4Oe9X2Jc6LBDZRD5iwg.5bgtw+6IMj
tZRNoQzOoIz6nAz6u4yOswy0os0WCm+ve7v+ELWrX3.
-----------end_max5_patcher-----------

Yes, sorry, bases not values. The problem (for Max) being that this is a 2D JSON array (an array of arrays). 1D arrays turn into lists just fine, 2D (and above) Max can’t transcode (we could start a petition to make lllls native :wink: )

What comes out of the JS is a jitter matrix* (which essentially get passed by refernece, like dicts), so you can plug the jit.cellblock straight in, to see what’s happening:


----------begin_max5_patcher----------
2668.3oc6bszbiiaD9r8uBTp1So7nP7fuxoYOjpRNjbYRU4vVaoBhDxlyPQx
P.4wd2Z8u8fGjRjRjzP1fRtRFM0XZAPRf9qeftaf1+9s2rXc4SL9BveA7Kfa
t42u8lazMoZ3llueyhszmRxob8ss3qYhkIr7704kIeawcl6XSYgXCMgotCul
1pK+t9IfMe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dUkFzd5PrsvC7SXn1NPHaFInCFHH1lAx2EiDwhQJzECje2vFGK74vdyli7jE
EfzYcPdI7j0R7BLm6xS5yEy6WkUD3JDB9JiTrKX5DanIjK35AVvzgDGLPg1X
CvELo.KFHWHMDaCOh3BoAj2EB6v1XA3Tyml0GNpboUiwQkI8QkH8okG83kF8
wkEsNnhwJG5a+ia+uZgiMtA
-----------end_max5_patcher-----------
1 Like

* ‘A jitter matrix’ = the symbol jit_matrix followed by a name, just as dicts are passed as dictionary [name]. Then, objects that take messages jit_matrix or dictionary ‘know’ what to do when one of these things hits them (look up the name and retrieve the object). Lists do the same sort of thing, but this is rendered invisible by Max (and signals work this way too).

1 Like

Ok, got there in the end.

I was really confused as to why I was getting a matrix as the output (e.g. 21x21) when I had a 1700x21 space, and asked for 3 dimensions out of fluid.pca~, but I guess that’s how fluid.pca~ computes stuff.

Not just fluid.pca~ :wink: It’s pretty common (almost universal) to express PCA in terms of a matrix multiplication, because they are – quite literally – a system for describing linear transformations of numbers. When you ask for a certain number of dimensions from PCA, what you get back is the matrix product of your input point and that number of cols of the bases matrix.

Because it’s magic, the result of matrix multiplying a 1x21 input point with a 21x3 matrix is a 1x3 output point:

So, in order to allow us to change our mind about @numdimensions without recomputing the whole decomposition every time, the PCA object stores the n*n matrix needed to ‘encode’ input points in any dimensionality up to n.

1 Like

Good to know.

So for the purposes of what’s going on in this thread, it doesn’t matter what @numdimensions you ask for, as you can compute however many components you want from the matrix?

with the limits of lists indeed… 32k is high for this but often low as you know…

Even in Max land you can infinite (iterated) lists. I don’t know if we’ll be dealing with single points with 32k vectors any time soon.

Indeed. If all you’re going to do is dump anyway, you also don’t need fittransform – just call fit instead (unless you want the PCA’d points for something else – they can be useful when debugging some of this outside-the-object stuff, to make sure that you can create the object’s results etc.). Getting the same result as transformpoint could be acheived with jit.la.mult (but it’s slightly fiddly in terms of making sure the orientations are all correct).

Meanwhile, the whole 32k thing is a red-herring. The problem is the dimensionality: in the absence of llll or similar, Max has no native way to deal with a list-within-a-list as something it can push out of an outlet (I guess they could have used a jitter matrix for this particular case, but in general, a JSON array can contain anything, including more JSON objects, which Jitter wouldn’t work for).

Longer term, I guess we’ll mop up a range of the edge cases that people resort to dicts for by adding to the objects themselves, and, if we can, think of some way to deal with this nested array problem.

2 Likes