Hacker News new | past | comments | ask | show | jobs | submit login

I wrote a decision tree library (random forests, gradient boosting, etc) in Go while learning the language (https://github.com/ajtulloch/decisiontrees).

It's nice being able to trivially parallelise operations in Go - e.g. constructing the weak learners for a random forest, generating candidate splits, recursing down left and right branches, etc.

    // Recur down the left and right branches in parallel
    w := sync.WaitGroup{}
    recur := func(child **pb.TreeNode, e Examples) {
        w.Add(1)
        go func() {
            *child = c.generateTree(e, currentLevel+1)
            w.Done()
        }()
    }

    recur(&tree.Left, examples[bestSplit.index:])
    recur(&tree.Right, examples[:bestSplit.index])
    w.Wait()
As you said, generics and a matrix library would be make the experience nicer. Just having

    sort :: Ord a => [a] -> [a]
would strip a decent amount of mildly error-prone boilerplate, and there are other cases (splits for cross-validation, etc) where it would be nice to be able to abstract over the type of the slice, etc.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: