Big Data/Analytics Zone is brought to you in partnership with:

Justin Bozonier is the Product Optimization Specialist at GrubHub formerly Sr. Developer/Analyst at Cheezburger. He's engineered a large, scalable analytics system, worked on actuarial modeling software. As Product Optimization Specialist he is currently leading split test design, implementation, and analysis. The opinions expressed here represent my own and not those of my employer. Justin is a DZone MVB and is not an employee of DZone and has posted 27 posts at DZone. You can read more from them at their website. View Full User Profile

Visualizing Multidimensional Data in Two Dimensions

02.21.2013
| 1740 views |
  • submit to reddit

Recently I ran into an issue where I had multidimensional data and didn't have an effective way to visualize it. Those who are less visual and more abstract are content to explore multidimensional data mathematically. If you're like me however you're visual and you want to see the shape of your data.
Enter star coordinates.
What are they? Here's my quick explanation then I'll direct you to the paper that taught me about them. Say you have a three dimensional point (3, 4, 5). You would go a distance of three along what you would normally call the x-axis. Next, and here is where it gets more interesting, pretend you're the point and turn (2 * pi) / dimension_count (three in this case) and then walk 4 units in this direction. Turn again and walk 5 units.
So theory is always great but here's how I implemented it and what my version looks like when graphing 4 dimensions.
The first thing I worked on was plotting a single point. I ended up with this solution:
var draw_point = function(ctx, origin_pixel, scale, row){
  var axial_rotation = (2 * Math.PI)/row.length;
  
  var final_point = {x:0, y:0};
  
  for(var i in row){
    final_point.x += scale[i] * row[i] * Math.cos(i * axial_rotation);
    final_point.y -= scale[i] * row[i] * Math.sin(i * axial_rotation);
  }
  ctx.fillRect(origin_pixel.x + final_point.x, origin_pixel.y + final_point.y, 2, 2);
};
Two things are involved, using some trigonometry to figure out how to move along the x and y axes for each dimension and aggregating them into a single point. You'll see in the code I have something I call "axial_rotation" that's how much I need to rotate as I step through each dimension of the point.
I didn't end up finding anything worth while in my data but maybe this technique will help me in the future... or maybe even help you.
I'm not 100% certain it's perfect. If anyone happens upon this and finds an error I'd love to know about it.

Published at DZone with permission of Justin Bozonier, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)