leaves icon indicating copy to clipboard operation
leaves copied to clipboard

Gonum/mat

Open sbinet opened this issue 7 years ago • 2 comments

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.)

sbinet avatar Sep 18 '18 19:09 sbinet

@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 avatar Sep 18 '18 19:09 dmitryikh

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?

dmitryikh avatar Sep 19 '18 19:09 dmitryikh