jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
linear_function_mixer.hpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2013 Preferred Networks and Nippon Telegraph and Telephone Corporation.
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License version 2.1 as published by the Free Software Foundation.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 #ifndef JUBATUS_CORE_FRAMEWORK_LINEAR_FUNCTION_MIXER_HPP_
18 #define JUBATUS_CORE_FRAMEWORK_LINEAR_FUNCTION_MIXER_HPP_
19 
20 #include "jubatus/util/lang/shared_ptr.h"
21 
22 #include "../common/exception.hpp"
23 #include "../storage/storage_base.hpp"
24 #include "../unlearner/unlearner_base.hpp"
25 
26 #include "linear_mixable.hpp"
27 #include "diffv.hpp"
28 
29 namespace jubatus {
30 namespace core {
31 namespace framework {
32 
34  public:
36  typedef jubatus::util::lang::shared_ptr<model_type> model_ptr;
37 
38  explicit linear_function_mixer(model_ptr model)
39  : model_(model) {
40  if (!model) {
42  }
43  }
44 
46  jubatus::util::lang::shared_ptr<unlearner::unlearner_base>
47  label_unlearner) {
48  label_unlearner_ = label_unlearner;
49  }
50 
51  model_ptr get_model() const {
52  return model_;
53  }
54 
55  void mix(const diffv& lhs, diffv& mixed) const;
56  void get_diff(diffv&) const;
57  bool put_diff(const diffv& v);
58 
59  // linear mixable
60  diff_object convert_diff_object(const msgpack::object&) const;
61  void mix(const msgpack::object& obj, diff_object) const;
62  void get_diff(packer&) const;
63  bool put_diff(const diff_object& obj);
64 
65  jubatus::util::lang::shared_ptr<unlearner::unlearner_base>
66  get_unlearner() const {
67  return label_unlearner_;
68  }
69 
70  private:
71  model_ptr model_;
72  jubatus::util::lang::shared_ptr<unlearner::unlearner_base> label_unlearner_;
73 };
74 
75 } // namespace framework
76 } // namespace core
77 } // namespace jubatus
78 
79 #endif // JUBATUS_CORE_FRAMEWORK_LINEAR_FUNCTION_MIXER_HPP_
void mix(const diffv &lhs, diffv &mixed) const
void set_label_unlearner(jubatus::util::lang::shared_ptr< unlearner::unlearner_base > label_unlearner)
jubatus::util::lang::shared_ptr< diff_object_raw > diff_object
jubatus::util::lang::shared_ptr< unlearner::unlearner_base > get_unlearner() const
diff_object convert_diff_object(const msgpack::object &) const
#define JUBATUS_EXCEPTION(e)
Definition: exception.hpp:79
std::vector< T > v(size)
jubatus::util::lang::shared_ptr< model_type > model_ptr
jubatus::util::lang::shared_ptr< unlearner::unlearner_base > label_unlearner_