Class: Jubatus::Classifier::LabeledDatum

Inherits:
Object
  • Object
show all
Includes:
Jubatus::Common
Defined in:
lib/jubatus/classifier/types.rb

Constant Summary collapse

TYPE =
TTuple.new(TString.new, TDatum.new)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Jubatus::Common

check_type, check_types

Constructor Details

#initialize(label, data) ⇒ LabeledDatum

Returns a new instance of LabeledDatum.


47
48
49
50
# File 'lib/jubatus/classifier/types.rb', line 47

def initialize(label, data)
  @label = label
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data


71
72
73
# File 'lib/jubatus/classifier/types.rb', line 71

def data
  @data
end

#labelObject (readonly)

Returns the value of attribute label


71
72
73
# File 'lib/jubatus/classifier/types.rb', line 71

def label
  @label
end

Class Method Details

.from_msgpack(m) ⇒ Object


57
58
59
60
# File 'lib/jubatus/classifier/types.rb', line 57

def LabeledDatum.from_msgpack(m)
  val = TYPE.from_msgpack(m)
  LabeledDatum.new(*val)
end

Instance Method Details

#to_msgpack(out = '') ⇒ Object


52
53
54
55
# File 'lib/jubatus/classifier/types.rb', line 52

def to_msgpack(out = '')
  t = [@label, @data]
  return TYPE.to_msgpack(t)
end

#to_sObject


62
63
64
65
66
67
68
69
# File 'lib/jubatus/classifier/types.rb', line 62

def to_s
  gen = Jubatus::Common::MessageStringGenerator.new
  gen.open("labeled_datum")
  gen.add("label", @label)
  gen.add("data", @data)
  gen.close()
  return gen.to_s
end