Kdtree with weighting on nearest?

Hi!

Im looking for some suggestions/thoughts on the following idea: I have this idea to use the kdtree to search for nearest neighbors, but with the option to let if focus on specific parts of the original dataset. For example if I have analyzed a bunch of sounds for many different descriptors I would like to be able to adjust in real time how much of which descriptor weighs in for the search of a nearest neighbor, basically allowing if some weights are set to 0 to ignore that part of the dataset. I’m curious on your thoughts if this could be achieved with fluid.kdtree~ or if you have any pointers to what I could look into to try and make this myself.

Hi,
I am a SuperCollider user, and to manage this kind of question, I set the numNeighbours at 0, that is to say all sorted points, and then with the action of the method kNearest I select the point that fit the condition I want.
Hope this helps.
Y

Hey! thanks for the suggestion, but im not entirely sure this fits my idea. But maybe i misunderstand. Let me clarify my idea:

Say i have analyzed a buffer for pitch, loudness, spread and centroid. Now I have the dataset in a kdtree (i’m using Max btw) and can find the nearest points with knearest. But what if i want (in real-time) to decide i want to exclude the pitch and loudness and only focus on finding nearest neighbors for spread and centroid. I imagine i like to send a list of weights for every column in the dataset to be included or not, something like (weight 0 0 1 1). Or even using floating points to have for example the loudness weigh in more then others (weight 0.1 1 0.2 0.3), etc.

I see. It seems that you have no choice, if you want the focus on some parameters, you have to make a dedicated kdtree (which can be done dynamically but takes a bit of time) or play by scaling the parameters in order to make some kind of weighing (but it needs to be done beforehand, when you initiate the kdtree).
By the way, it will be nice to combinate kNearest and kNearestDist in a single action as pairs, I mean as a single method unless it exits a trick to do it?

hello

indeed, you can make sub-datasets with datasetquery (if you only want to include or exclude dimensions/descriptors) - building a tree is not very long but doing it at each query is suboptimal indeed. It is worth trying your workflow first, to see what results you get.

There was a thread last year where @weefuzzy made a sort of GUI to help @rodrigo.constanzo remembering what dimension was what - a sort of script to help you assembling your subdataset.