Sha256: 3d4bd37894af1c693e37c7a69426ff25250293b35ee9cc14969cacaf834a6b30
Contents?: true
Size: 832 Bytes
Versions: 1
Compression:
Stored size: 832 Bytes
Contents
module XLearn class DMatrix include Utils def initialize(data, label: nil) @handle = ::FFI::MemoryPointer.new(:pointer) nrow = data.count ncol = data.first.count c_data = ::FFI::MemoryPointer.new(:float, nrow * ncol) c_data.put_array_of_float(0, data.flatten) if label c_label = ::FFI::MemoryPointer.new(:float, nrow) c_label.put_array_of_float(0, label) end # TODO support this field_map = nil check_call FFI.XlearnCreateDataFromMat(c_data, nrow, ncol, c_label, field_map, @handle) ObjectSpace.define_finalizer(self, self.class.finalize(@handle)) end def to_ptr @handle end def self.finalize(pointer) # must use proc instead of stabby lambda proc { FFI.XlearnDataFree(pointer) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xlearn-0.1.0 | lib/xlearn/dmatrix.rb |