jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
classifier.hpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2011,2012 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_DRIVER_CLASSIFIER_HPP_
18 #define JUBATUS_CORE_DRIVER_CLASSIFIER_HPP_
19 
20 #include <map>
21 #include <string>
22 #include <vector>
23 #include "jubatus/util/lang/shared_ptr.h"
24 #include "../classifier/classifier_type.hpp"
25 #include "../framework/mixable.hpp"
26 #include "../fv_converter/mixable_weight_manager.hpp"
27 #include "driver.hpp"
28 
29 namespace jubatus {
30 namespace core {
31 namespace fv_converter {
32 class datum;
33 class datum_to_fv_converter;
34 } // namespace fv_converter
35 namespace classifier {
36 class classifier_base;
37 } // namespace classifier
38 namespace driver {
39 
40 class classifier : public driver_base {
41  public:
43 
44  // TODO(suma): where is the owner of model, mixer, and converter?
45  classifier(
46  jubatus::util::lang::shared_ptr<classifier_base>
47  classifier_method,
48  jubatus::util::lang::shared_ptr<fv_converter::datum_to_fv_converter>
49  converter);
50  virtual ~classifier();
51 
52  void train(const std::string&, const fv_converter::datum&);
53 
55  const fv_converter::datum& data) const;
56 
57  void get_status(std::map<std::string, std::string>& status) const;
58  bool delete_label(const std::string& name);
59 
60  void clear();
61  void pack(framework::packer& pk) const;
62  void unpack(msgpack::object o);
63 
64  std::vector<std::string> get_labels() const;
65  bool set_label(const std::string& label);
66 
67  private:
68  jubatus::util::lang::shared_ptr<fv_converter::datum_to_fv_converter>
70  jubatus::util::lang::shared_ptr<classifier_base> classifier_;
72 };
73 
74 } // namespace driver
75 } // namespace core
76 } // namespace jubatus
77 
78 #endif // JUBATUS_CORE_DRIVER_CLASSIFIER_HPP_
std::vector< classify_result_elem > classify_result
classifier(jubatus::util::lang::shared_ptr< classifier_base > classifier_method, jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converter > converter)
Definition: classifier.cpp:42
bool set_label(const std::string &label)
Definition: classifier.cpp:90
jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converter > converter_
Definition: classifier.hpp:69
jubatus::core::classifier::classify_result classify(const fv_converter::datum &data) const
Definition: classifier.cpp:64
void train(const std::string &, const fv_converter::datum &)
Definition: classifier.cpp:57
void pack(framework::packer &pk) const
Definition: classifier.cpp:94
core::classifier::classifier_base classifier_base
Definition: classifier.hpp:42
bool delete_label(const std::string &name)
Definition: classifier.cpp:78
void unpack(msgpack::object o)
Definition: classifier.cpp:100
jubatus::util::lang::shared_ptr< classifier_base > classifier_
Definition: classifier.hpp:70
fv_converter::mixable_weight_manager wm_
Definition: classifier.hpp:71
std::vector< std::string > get_labels() const
Definition: classifier.cpp:87
void get_status(std::map< std::string, std::string > &status) const
Definition: classifier.cpp:74