jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
clustering.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_DRIVER_CLUSTERING_HPP_
18 #define JUBATUS_CORE_DRIVER_CLUSTERING_HPP_
19 
20 #include <utility>
21 #include <vector>
22 #include "jubatus/util/lang/shared_ptr.h"
23 #include "../clustering/types.hpp"
24 #include "../framework/mixable.hpp"
25 #include "../fv_converter/datum.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 clustering {
36 class clustering;
37 } // namespace clustering
38 namespace driver {
39 
40 class clustering : public driver_base {
41  public:
42  clustering(
43  jubatus::util::lang::shared_ptr<core::clustering::clustering>
44  clustering_method,
45  jubatus::util::lang::shared_ptr<fv_converter::datum_to_fv_converter>
46  converter);
47  virtual ~clustering();
48 
49  void push(const std::vector<fv_converter::datum>& points);
50 
52  const fv_converter::datum& point) const;
54  const fv_converter::datum& point) const;
55 
56  std::vector<fv_converter::datum> get_k_center() const;
58 
59  size_t get_revision() const;
60  void pack(framework::packer& pk) const;
61  void unpack(msgpack::object o);
62 
63  // for test only
64  void do_clustering();
65 
66  void clear();
67 
68  private:
71  fv_converter::datum to_datum(const common::sfv_t& src) const;
73  const fv_converter::datum& src);
74  std::pair<double, fv_converter::datum>
76  std::vector<fv_converter::datum> to_datum_vector(
77  const std::vector<common::sfv_t>& src) const;
78  std::vector<core::clustering::weighted_point> to_weighted_point_vector(
79  const std::vector<fv_converter::datum>& src);
81  const std::vector<core::clustering::weighted_point>& src) const;
82 
83  jubatus::util::lang::shared_ptr<fv_converter::datum_to_fv_converter>
85  jubatus::util::lang::shared_ptr<core::clustering::clustering> clustering_;
87 };
88 
89 } // namespace driver
90 } // namespace core
91 } // namespace jubatus
92 
93 #endif // JUBATUS_CORE_DRIVER_CLUSTERING_HPP_
core::clustering::weighted_point to_weighted_point(const fv_converter::datum &src)
Definition: clustering.cpp:124
common::sfv_t to_sfv(const fv_converter::datum &dat)
Definition: clustering.cpp:104
fv_converter::datum to_datum(const common::sfv_t &src) const
Definition: clustering.cpp:118
core::clustering::cluster_unit get_nearest_members(const fv_converter::datum &point) const
std::vector< cluster_unit > cluster_set
Definition: types.hpp:37
core::clustering::cluster_set get_core_members() const
Definition: clustering.cpp:77
fv_converter::datum get_nearest_center(const fv_converter::datum &point) const
std::vector< std::pair< cluster_weight, jubatus::core::fv_converter::datum > > cluster_unit
Definition: types.hpp:36
std::vector< fv_converter::datum > get_k_center() const
Definition: clustering.cpp:72
std::vector< core::clustering::weighted_point > to_weighted_point_vector(const std::vector< fv_converter::datum > &src)
Definition: clustering.cpp:153
void pack(framework::packer &pk) const
Definition: clustering.cpp:182
std::pair< double, fv_converter::datum > to_weighted_datum(const core::clustering::weighted_point &src) const
Definition: clustering.cpp:133
std::vector< fv_converter::datum > to_datum_vector(const std::vector< common::sfv_t > &src) const
Definition: clustering.cpp:138
jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converter > converter_
Definition: clustering.hpp:84
fv_converter::mixable_weight_manager wm_
Definition: clustering.hpp:86
jubatus::util::lang::shared_ptr< core::clustering::clustering > clustering_
Definition: clustering.hpp:85
clustering(jubatus::util::lang::shared_ptr< core::clustering::clustering > clustering_method, jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converter > converter)
common::sfv_t to_sfv_const(const fv_converter::datum &dat) const
Definition: clustering.cpp:111
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29
core::clustering::cluster_unit to_weighted_datum_vector(const std::vector< core::clustering::weighted_point > &src) const
Definition: clustering.cpp:168
void push(const std::vector< fv_converter::datum > &points)
void unpack(msgpack::object o)
Definition: clustering.cpp:188