1 #ifndef GRAIL_DECISION_TREE_BINARY_SERIALIZER_H
2 #define GRAIL_DECISION_TREE_BINARY_SERIALIZER_H
4 #include "IDecisionTreeSerializer.hh"
5 #include "IDecisionSerializers.hh"
15 template <
class TDecisionType>
26 outStream { outStream},
28 actionSerializer { std::move(actionSerializer)}
42 actionSerializer{ std::move(actionSerializer) }
50 outStream->write(
reinterpret_cast<char*
>(&val),
sizeof(val));
56 char m[
sizeof(size_t)];
57 inStream->read(m,
sizeof(T));
58 T* val =
reinterpret_cast<T*
>(m);
65 Write(
static_cast<int>(nodeType));
73 return DecisionNodeType::NOMINAL_INNER;
75 return DecisionNodeType::CONTINUOUS_INNER;
77 return DecisionNodeType::LEAF;
101 return Read<float>();
122 actionSerializer->Serialize(decision, *outStream);
128 return actionSerializer->Deserialize(*inStream);
132 std::ostream* outStream;
133 std::istream* inStream;
134 std::unique_ptr<IDecisionBinarySerializer<TDecisionType>> actionSerializer;
Used to serialize decision tree in a binary mode. Pass object of this type to the DecisionTree....
Definition: DecisionTreeBinarySerializer.hh:17
virtual int DeserializeColumnIndex() override
Inherited from IDecisionTreeSerializer.
Definition: DecisionTreeBinarySerializer.hh:87
virtual void SerializeNodeType(DecisionNodeType nodeType) override
Inherited from IDecisionTreeSerializer.
Definition: DecisionTreeBinarySerializer.hh:63
virtual void SerializeDecision(const TDecisionType &decision) override
Inherited from IDecisionTreeSerializer.
Definition: DecisionTreeBinarySerializer.hh:120
virtual std::unique_ptr< TDecisionType > DeserializeDecision() override
Inherited from IDecisionTreeSerializer.
Definition: DecisionTreeBinarySerializer.hh:126
virtual void SerializeColumnIndex(int columnIndex) override
Inherited from IDecisionTreeSerializer.
Definition: DecisionTreeBinarySerializer.hh:81
virtual DecisionNodeType DeserializeNodeType() override
Inherited from IDecisionTreeSerializer.
Definition: DecisionTreeBinarySerializer.hh:69
virtual float DeserializeValue() override
Inherited from IDecisionTreeSerializer.
Definition: DecisionTreeBinarySerializer.hh:99
virtual void SerializeChildrenCount(int count) override
Inherited from IDecisionTreeSerializer.
Definition: DecisionTreeBinarySerializer.hh:106
virtual int DeserializeChildrenCount() override
Inherited from IDecisionTreeSerializer.
Definition: DecisionTreeBinarySerializer.hh:113
virtual void SerializeValue(float value) override
Inherited from IDecisionTreeSerializer.
Definition: DecisionTreeBinarySerializer.hh:93
DecisionTreeBinarySerializer(std::unique_ptr< IDecisionBinarySerializer< TDecisionType >> actionSerializer, std::istream *inStream)
Constructs a new DecisionTreeBinarySerializer object. This constructor is used for deserialization on...
Definition: DecisionTreeBinarySerializer.hh:39
DecisionTreeBinarySerializer(std::unique_ptr< IDecisionBinarySerializer< TDecisionType >> actionSerializer, std::ostream *outStream)
Constructs a new DecisionTreeBinarySerializer object. This constructor is used for serialization only...
Definition: DecisionTreeBinarySerializer.hh:25
Definition: IDecisionSerializers.hh:32
A base class for an object that is passed to Serialize() and Deserialize() methods of DecisionTree....
Definition: IDecisionTreeSerializer.hh:21