
I am trying to represent the data on this ternary graph for lookup. I would like to be able to feed all three values into a function and get back which area category these values fall into. The approach I am looking at is translating each area into a polygon using Cartesian coordinates. Then translating the supplied values into a point and checking if that point lies inside which polygon. I am pretty sure that will work but it just seems like an overkill for a simple lookup?
I am asking if there is a way to represent the data on this graph in an array or an object so that a simple lookup would be enough?
You could translate the above into the Cartesian coordinate system, but there I think you’re missing the important aspect of what it would take to actually do this.
In the above diagram, you are looking at the polygons as two-dimensional structures, but you have a three-dimensional point. It’s not impossible, after all, we see the triangle on a two-dimensional plane above, but the translation into Cartesian space isn’t exactly straightforward.
Rather, this looks very much like a graphical representation of a decision tree. It looks like readings for the amount of clay, silt and sand were taken to develop this representation.
Basically, you have a tuple of three values, and you want to get a classification depending on those values.
In the case above, you can model the decision tree for the classification “silt” as:
Each
if/elsestatement represents a branch in the decision tree. At each branch, you’ll want to evaluate value of the variable that at that point in the branch gives you the most information gain (pretty much what it sounds like, how many classifications can you make off that split?) which is based on the entropy (or uncertainty) that making a decision on that variable has.The trees can be generated automatically or, you can manually code it yourself. While the latter is possible, I strongly suggest an automated/code-based method to develop it. I’d strongly suggest taking a look at Accord.NET (which requires AForge.NET, both are excellent). To get you started, you should take a look at this blog post showing how to create decision trees using Accord.NET.
Whichever way you go, you’ll ultimately get a function that takes the three values (clay, silt, and sand) and returns your classification, traversing the tree depending on the values of each.
Note that you aren’t necessarily going to have a one-to-one set of criteria (branches) that will map to each classification (as seen in the first code sample). Depending on the number of vertices on the polygons in the example above, you will need additional branches to handle those situations.
If you have the original sample data, then you just have to run the sample data through your decision tree builder and it should create a decision tree like the one above.
If you don’t have the original sample data, you can create it using the vertices from above and classifying those. For example:
Regarding the last row (and subsequent ones), the decision tree will set a boundary based on those values, and because it’s continuous it will usually make a decision based on all values greater than or equal to that value.