dmitryikh / leaves

pure Go implementation of prediction part for GBRT (Gradient Boosting Regression Trees) models from popular frameworks
MIT License
419 stars 72 forks source link

Gonum/mat #12

Open sbinet opened 5 years ago

sbinet commented 5 years ago

Currently, leaves uses a standalone matrix implementation that's almost completely binary compatible with gonum/mat.Dense implementation.

It would be very beneficial to just use the one from gonum/mat. (Or, at least, implement the mat.Matrix interface.)

dmitryikh commented 5 years ago

@sbinet , thanks for your comment.

For now models implement raw data structure interfaces as below"

// PredictCSR calculates predictions from ensembles of trees. `indptr`, `cols`,
// `vals` represent data structures from Compressed Sparse Row Matrix format (see CSRMat)....
func (e *XGEnsemble) PredictCSR(indptr []uint32, cols []uint32, vals []float64, predictions []float64, nTrees int, nThreads int)
// PredictDense calculates predictions from ensembles of trees. `vals`, `rows`,
// `cols` represent data structures from Rom Major Matrix format (see DenseMat).
func (e *XGEnsemble) PredictDense(vals []float64, nrows uint32, ncols uint32, predictions []float64, nTrees int, nThreads int) error

Standalone matrix implementations are here just to make it easy to perform tests.

I will have a look to gonum

dmitryikh commented 5 years ago

After #14 , here is full binary compatibility to use gonum/mat.Dense without type conversions.

As far as I know here is no Sparse matrix implementations in gonum (like Compressed Sparse Row format) to adapt PredictCSR to it.

@sbinet , what do you think should leaves have some additional support of gonum matrices?