mikeizbicki / HLearn

Homomorphic machine learning
Other
1.63k stars 138 forks source link

Messing with Perceptron #25

Closed MattWis closed 10 years ago

MattWis commented 10 years ago

This pull request is two different things, I'm just being lazy. I can submit them separately if you'd like.

The Perceptron example has it's Y-axis flipped, so I fixed that to make the printout better.

The larger part is me starting on an automated test suite, and including some basic Perceptron tests based on the Perceptron example.

MattWis commented 10 years ago

Sorry, I got distracted.

I don't have experience writing tests for Haskell, but I was test-driving Ruby on Rails code all summer. I am trying to simultaneously learn how to write a good test suite for Haskell, as well as machine learning, and figured that this repository makes for a pretty good marriage of the interests.

The general way to structure tests are to have a separate test directory that mirrors the src directory, with the same files but a Spec appended to the name. I have the skeleton of that laid out now.

I added an associativity test for the MonoidChain (I searched for where you had quickCheck's), and will go through the codebase to find other Monoid instances that should be tested as well, (hopefully) figuring out how they work as I go.

mikeizbicki commented 10 years ago

Cool! That sounds awesome! Let me know if I can help in any way.

One of the things I was having trouble with testing was that there's no good way to use quickcheck for "approximate associativity." For example, if we're using Doubles, then (a+b)+c is not guaranteed to equal a+(b+c), but it's going to be really, really close. Thus, the Normal distribution for example will not pass the associative quickcheck property despite the fact that for most practical purposes it's good to go.

What I'd really like is a small extension to quickcheck that goes beyond just pass/fail and can report a numerical score. Then for these almost associative structures we could just set the score to some appropriate threshold to automate the tests.

mikeizbicki commented 10 years ago

I'm having trouble following your commits. It looks like maybe you're working on a branch that's a few commits old, so your commits are undoing a lot of the changes I've made over the past week.

Maybe you need to update your local repository first and then issue the pull request?

Okay, I see now. The first commit was just bringing everything up to date. I've never seen it lump it all into a commit like that before.