jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
anomaly_base.hpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 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_ANOMALY_ANOMALY_BASE_HPP_
18 #define JUBATUS_CORE_ANOMALY_ANOMALY_BASE_HPP_
19 
20 #include <string>
21 #include <vector>
22 
23 #include "jubatus/util/data/unordered_map.h"
24 #include "jubatus/util/lang/shared_ptr.h"
25 
26 #include "../common/type.hpp"
27 #include "../framework/mixable.hpp"
28 #include "../framework/model.hpp"
29 #include "../storage/sparse_matrix_storage.hpp"
30 #include "anomaly_type.hpp"
31 
32 namespace jubatus {
33 namespace core {
34 namespace anomaly {
35 
37  public:
38  anomaly_base();
39  virtual ~anomaly_base();
40 
41  // Calculates and returns anomaly score of given query.
42  virtual float calc_anomaly_score(const common::sfv_t& query) const = 0;
43 
44  // Returns anomaly score of the row corresponding to given id.
45  virtual float calc_anomaly_score(const std::string& id) const = 0;
46 
47  virtual void pack(framework::packer& packer) const = 0;
48  virtual void unpack(msgpack::object o) = 0;
49 
50  virtual bool is_updatable() const = 0;
51 
52  // Clears all rows.
53  virtual void clear() = 0;
54 
55  // Removes the row corresponding to given id.
56  //
57  // The removal event must be shared among other MIX participants. Thus,
58  // typical implementation does not eliminate the row immediately but marks it
59  // as "removed" instead. Some implementations including light_lof do not
60  // support this function.
61  virtual void clear_row(const std::string& id) = 0;
62 
63  // Partially updates the row corresponding to given id.
64  //
65  // Some implementations including light_lof do not support this function.
66  virtual void update_row(const std::string& id, const sfv_diff_t& diff) = 0;
67 
68  // Updates the row corresponding to given id.
69  //
70  // Some implementations including lof do not support this function.
71  virtual void set_row(const std::string& id, const common::sfv_t& sfv) = 0;
72 
73  virtual void get_all_row_ids(std::vector<std::string>& ids) const = 0;
74  virtual std::string type() const = 0;
75  virtual std::vector<framework::mixable*> get_mixables() const = 0;
76 
77  uint64_t find_max_int_id() const;
78 };
79 
80 } // namespace anomaly
81 } // namespace core
82 } // namespace jubatus
83 
84 #endif // JUBATUS_CORE_ANOMALY_ANOMALY_BASE_HPP_
virtual void get_all_row_ids(std::vector< std::string > &ids) const =0
virtual std::vector< framework::mixable * > get_mixables() const =0
virtual void pack(framework::packer &packer) const =0
virtual float calc_anomaly_score(const common::sfv_t &query) const =0
virtual void clear_row(const std::string &id)=0
virtual std::string type() const =0
virtual void unpack(msgpack::object o)=0
common::sfv_t sfv_diff_t
virtual bool is_updatable() const =0
msgpack::packer< jubatus_packer > packer
Definition: bandit_base.hpp:31
virtual void set_row(const std::string &id, const common::sfv_t &sfv)=0
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29
virtual void update_row(const std::string &id, const sfv_diff_t &diff)=0