Class: Xgb::DMatrix
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
- #handle_pointer ⇒ Object
-
#initialize(data, label: nil, weight: nil, missing: Float::NAN) ⇒ DMatrix
constructor
A new instance of DMatrix.
- #num_col ⇒ Object
Constructor Details
#initialize(data, label: nil, weight: nil, missing: Float::NAN) ⇒ DMatrix
Returns a new instance of DMatrix.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/xgb/dmatrix.rb', line 5 def initialize(data, label: nil, weight: nil, missing: Float::NAN) @data = data @label = label @weight = weight c_data = ::FFI::MemoryPointer.new(:float, data.count * data.first.count) c_data.put_array_of_float(0, data.flatten) @handle = ::FFI::MemoryPointer.new(:pointer) check_result FFI.XGDMatrixCreateFromMat(c_data, data.count, data.first.count, missing, @handle) set_float_info("label", label) if label end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/xgb/dmatrix.rb', line 3 def data @data end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
3 4 5 |
# File 'lib/xgb/dmatrix.rb', line 3 def label @label end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
3 4 5 |
# File 'lib/xgb/dmatrix.rb', line 3 def weight @weight end |
Instance Method Details
#handle_pointer ⇒ Object
24 25 26 |
# File 'lib/xgb/dmatrix.rb', line 24 def handle_pointer @handle.read_pointer end |
#num_col ⇒ Object
18 19 20 21 22 |
# File 'lib/xgb/dmatrix.rb', line 18 def num_col out = ::FFI::MemoryPointer.new(:long) FFI.XGDMatrixNumCol(handle_pointer, out) out.read_long end |