Wrote some code, but may change to mlpack library.