Generating Insight With Cody Function Clouds
One of the things I like about Cody is that it not only encourages you to solve a particular problem, but it encourages you to solve it many different ways. Even better, after you’ve done your best, you can look at how other people solve the same problem. This is often the most enlightening part of the Cody process. I am always surprised and often delighted when I look at other people’s solutions. As I do so, you’re likely to hear me mumbling things like “I didn’t know you could do that” or “That never would have occurred to me” or even “I’ve never heard of that function before!”
Let me give you an example of learning from Cody. Specifically from Problem 661: Spot the outlier. Which of these points is not located on a single line?
If I show you the points as numbers, it’s a little tricky to work it out. But once you see it on a plot, it’s quite easy. Easy for you, but how would you teach MATLAB to solve this problem?
Let’s look at how people solved this one. First of all here is the Solution Map for all the solutions so far.
We can see that the size ranges from 12 to around 200 with a handful of answers even bigger than that. And there are more than twice as many wrong answers as correct answers. But beyond that, there’s not a lot of insight to be gained here.
Here’s a histogram of the size of all the correct answers.
Now we can see that most of the correct answers come in at around size=70. That shows how many people are solving the problem. But how are they solving it? We can sift through individual solutions, but it would be nice if there were some way we could get some insight into lots of solutions at once. One way to do this is with a function cloud. First we boil each solution down until it’s just list of functions. Then we can build up a word cloud with these functions. Thus: function cloud. Here’s a function cloud for all 323 correct solutions received so far.
It’s kind of a mess, but you can get some ideas from what you see there: polyarea, corrcoef, detrend, nchoosek. Each one of these is a clue worth puzzling over. But let’s try another tactic. Let’s make a function cloud of the smallest correct solutions.
Hmmm. Clearly delaunay is the key here. But how? The Delaunay triangulation returns a list of triangles based on the points you give it. By virtue of being the one point that’s off the line, point 2 shows up in all the triangles returned by delaunay. That means that its index, 2, appears in the matrix tri more than any other number. So the mode of the numbers in the matrix is our answer: 2.
It never would have occurred to me to do it that way, but I’m sure glad Cody reminded of this useful function.
- 类别:
- Cody
评论
要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。