Ask HN: How to better grok the “curse of dimensionality”?
I've sort of stumbled onto this topic organically and now I'm rather curious. In the context of building a recommendation system, I understand the concept of a high dimensional space made of vectors, and how cosine similarity is a way to derive similarity between vectors regardless of their magnitude.
Naturally I was curious about using simple distance-based calculations instead, and I'm hearing about the curse of dimensionality. I think I sort of get it but only on a surface level, not very deeply.
I'm also curious if it's possible to take any high dimensional space and somehow convert it into a weighted graph instead? And if there are recommendation/similarity systems based on this approach instead, and basically how all of this works in general at a holistic level.
I find 3Blue1Brown's videos (like https://www.youtube.com/watch?v=WUvTyaaNkzM) to be so good at explaining subject matter. Is there anything in this format that really helps illustrate all of this new material I'm referring to?
7 comments
[ 3.1 ms ] story [ 30.2 ms ] threadA simple case to visualize that is not related to machine learning is to solve a PDE numerically. Typically this is done via some form of discretization. If you were to solve the PDE in 2D by discretizing a region into, say, a 10x10 grid, then you need to compute the solution at 100 points. If you were to solve the same PDE in a cube, and discretize it similarly, you now need to solve it at 1000 points. Thus, scaling to higher dimensional PDEs rapidly becomes intractable even if the PDE isn’t becoming harder to solve (e.g. resulting linear equations remain equally well conditioned).
In the case of learning, you want your samples to capture behaviors over some region of space. As the number of dimensions increases, so does the volume of space you must gain information from, and thus so does the number of samples you need to explore that space.
The compression you mention is actually a pretty big topic across fields called dimensionality reduction. The idea is that, despite whatever physical process is generating your data (in learning, PDE solving, etc.) giving you a high dimensional vector, this data lives on some lower dimensional manifold (basically you can describe it’s location using a relatively small number of coordinates, e.g. if your data lies on the radius of a unit circle, then a datum is a point in 2D space but you only need to tell me an angle from the origin for each data point). If you can determine this manifold, then any subsequent computation is easier because you can work in a lower dimensional space. The question then is how to find this manifold?
Regarding distances, I don’t quite understand your question, but consider this: there is a difference between distance on a manifold and distance in the Euclidean space in which that manifold lives. For example, the straight-line distance between me and you is not the distance I need to walk to get to you. The former clips through the earth’s crust (thereby leaving the manifold which is the earth’s surface), is a lower bound on how far I need to walk to get to you, and this lower bound becomes a worse approximation the farther apart we are from one another. Therefore, you likely want your algorithm to work with the distance on the manifold as that is more physically meaningful. Finally, distances for mathematical / algorithmic purposes are really relative. You can’t just move the data to be closer together — that would be like setting your height equal to my height in a data base arbitrarily. If you rescale all the distances (convert our heights to kilometers, for example), that doesn’t change anything about the problem once you rescale everything else to respect that change. Finding this manifold and working with relevant distances on the manifold is basically trying to do compression while preserving the most meaningful properties of your data.
Simply put, when performing SVM you want to find a plane that minimizes the sum of its distance from coordinates belonging to two classes. The coordinates can be very high dimensional, which makes the minimization problem hard (primal formulation: $y = w^Tx + b$, w being the weights you need to estimate, which is equal to a very high dimension).
With help of the Lagrangian of the primal formulation, you can show that $x' ~ w^Tx + b ~ ayx^Tx + b$. So instead of having to estimate a very high number of w's, you can do away with only estimating the dot product x^Tx, which is limited by the number of inputs. This is the kernel trick you can use to avoid the curse of dimensionality.
One way to get around this is to take the cosine of the angle between the documents' respective vectors. While this often works better than the Euclidean distance, it is also affected by the curse of dimensionality. Afaik, there is no good way to work around the curse of dimensionality and similarity metrics not using vector representations often work better in practice. For example, one can model documents as bag-of-words and divide the size of the intersection with the size of the union.