jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
Public Member Functions | Private Attributes | List of all members
jubatus::core::driver::nearest_neighbor Class Reference

#include <nearest_neighbor.hpp>

Inheritance diagram for jubatus::core::driver::nearest_neighbor:
Inheritance graph
Collaboration diagram for jubatus::core::driver::nearest_neighbor:
Collaboration graph

Public Member Functions

void clear ()
 
std::vector< std::string > get_all_rows ()
 
jubatus::util::lang::shared_ptr< const storage::column_tableget_const_table () const
 
jubatus::util::lang::shared_ptr< storage::column_tableget_table ()
 
 nearest_neighbor (jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base > nn, jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converter > converter)
 
 nearest_neighbor (jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base > nn, jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converter > converter, jubatus::util::lang::shared_ptr< unlearner::unlearner_base > unlearner)
 
std::vector< std::pair< std::string, float > > neighbor_row_from_datum (const fv_converter::datum &datum, size_t size)
 
std::vector< std::pair< std::string, float > > neighbor_row_from_id (const std::string &id, size_t size)
 
void pack (framework::packer &pk) const
 
void set_row (const std::string &id, const fv_converter::datum &datum)
 
std::vector< std::pair< std::string, float > > similar_row (const std::string &id, size_t ret_num)
 
std::vector< std::pair< std::string, float > > similar_row (const core::fv_converter::datum &datum, size_t ret_num)
 
void unpack (msgpack::object o)
 
- Public Member Functions inherited from jubatus::core::driver::driver_base
 driver_base ()
 
virtual framework::mixableget_mixable ()
 
std::vector< storage::versionget_versions () const
 
virtual ~driver_base ()
 

Private Attributes

jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converterconverter_
 
jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_basenn_
 
jubatus::util::lang::shared_ptr< unlearner::unlearner_baseunlearner_
 
fv_converter::mixable_weight_manager wm_
 

Additional Inherited Members

- Protected Member Functions inherited from jubatus::core::driver::driver_base
void register_mixable (framework::mixable *mixable)
 
- Protected Attributes inherited from jubatus::core::driver::driver_base
mixable_holder holder_
 

Detailed Description

Definition at line 45 of file nearest_neighbor.hpp.

Constructor & Destructor Documentation

jubatus::core::driver::nearest_neighbor::nearest_neighbor ( jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base nn,
jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converter converter 
)
jubatus::core::driver::nearest_neighbor::nearest_neighbor ( jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base nn,
jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converter converter,
jubatus::util::lang::shared_ptr< unlearner::unlearner_base unlearner 
)

Member Function Documentation

void jubatus::core::driver::nearest_neighbor::clear ( )
virtual

Implements jubatus::core::driver::driver_base.

Definition at line 125 of file nearest_neighbor.cpp.

References converter_, nn_, and unlearner_.

125  {
126  converter_->clear_weights();
127  nn_->clear();
128  if (unlearner_) {
129  unlearner_->clear();
130  }
131 }
jubatus::util::lang::shared_ptr< unlearner::unlearner_base > unlearner_
jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base > nn_
jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converter > converter_
std::vector< std::string > jubatus::core::driver::nearest_neighbor::get_all_rows ( )

Definition at line 119 of file nearest_neighbor.cpp.

References nn_.

119  {
120  std::vector<std::string> ret;
121  nn_->get_all_row_ids(ret);
122  return ret;
123 }
jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base > nn_
shared_ptr< const storage::column_table > jubatus::core::driver::nearest_neighbor::get_const_table ( ) const

Definition at line 68 of file nearest_neighbor.cpp.

References nn_.

68  {
69  return nn_->get_const_table();
70 }
jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base > nn_
shared_ptr< storage::column_table > jubatus::core::driver::nearest_neighbor::get_table ( )

Definition at line 63 of file nearest_neighbor.cpp.

References nn_.

63  {
64  return nn_->get_table();
65 }
jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base > nn_
std::vector< std::pair< std::string, float > > jubatus::core::driver::nearest_neighbor::neighbor_row_from_datum ( const fv_converter::datum datum,
size_t  size 
)

Definition at line 91 of file nearest_neighbor.cpp.

References converter_, nn_, and jubatus::core::common::jsonconfig::v().

93  {
95  converter_->convert(datum, v);
96  std::vector<std::pair<std::string, float> > ret;
97  nn_->neighbor_row(v, ret, size);
98  return ret;
99 }
jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base > nn_
jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converter > converter_
std::vector< T > v(size)
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29

Here is the call graph for this function:

std::vector< std::pair< std::string, float > > jubatus::core::driver::nearest_neighbor::neighbor_row_from_id ( const std::string &  id,
size_t  size 
)

Definition at line 84 of file nearest_neighbor.cpp.

References nn_.

84  {
85  std::vector<std::pair<std::string, float> > ret;
86  nn_->neighbor_row(id, ret, size);
87  return ret;
88 }
jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base > nn_
void jubatus::core::driver::nearest_neighbor::pack ( framework::packer pk) const
virtual

Implements jubatus::core::driver::driver_base.

Definition at line 133 of file nearest_neighbor.cpp.

References jubatus::core::framework::linear_mixable_helper< Model, Diff >::get_model(), nn_, and wm_.

133  {
134  pk.pack_array(2);
135  nn_->pack(pk);
136  wm_.get_model()->pack(pk);
137 }
fv_converter::mixable_weight_manager wm_
jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base > nn_

Here is the call graph for this function:

void jubatus::core::driver::nearest_neighbor::set_row ( const std::string &  id,
const fv_converter::datum datum 
)

Definition at line 72 of file nearest_neighbor.cpp.

References converter_, nn_, unlearner_, and jubatus::core::common::jsonconfig::v().

74  {
75  if (unlearner_) {
76  unlearner_->touch(id);
77  }
79  converter_->convert_and_update_weight(datum, v);
80  nn_->set_row(id, v);
81 }
jubatus::util::lang::shared_ptr< unlearner::unlearner_base > unlearner_
jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base > nn_
jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converter > converter_
std::vector< T > v(size)
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29

Here is the call graph for this function:

std::vector< std::pair< std::string, float > > jubatus::core::driver::nearest_neighbor::similar_row ( const std::string &  id,
size_t  ret_num 
)

Definition at line 102 of file nearest_neighbor.cpp.

References nn_.

102  {
103  std::vector<std::pair<std::string, float> > ret;
104  nn_->similar_row(id, ret, ret_num);
105  return ret;
106 }
jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base > nn_
std::vector< std::pair< std::string, float > > jubatus::core::driver::nearest_neighbor::similar_row ( const core::fv_converter::datum datum,
size_t  ret_num 
)

Definition at line 109 of file nearest_neighbor.cpp.

References converter_, nn_, and jubatus::core::common::jsonconfig::v().

111  {
113  converter_->convert(datum, v);
114  std::vector<std::pair<std::string, float> > ret;
115  nn_->similar_row(v, ret, ret_num);
116  return ret;
117 }
jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base > nn_
jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converter > converter_
std::vector< T > v(size)
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29

Here is the call graph for this function:

void jubatus::core::driver::nearest_neighbor::unpack ( msgpack::object  o)
virtual

Implements jubatus::core::driver::driver_base.

Definition at line 139 of file nearest_neighbor.cpp.

References converter_, jubatus::core::framework::linear_mixable_helper< Model, Diff >::get_model(), nn_, and wm_.

139  {
140  if (o.type != msgpack::type::ARRAY || o.via.array.size != 2) {
141  throw msgpack::type_error();
142  }
143 
144  // clear
145  nn_->clear();
146  converter_->clear_weights();
147 
148  // load
149  nn_->unpack(o.via.array.ptr[0]);
150  wm_.get_model()->unpack(o.via.array.ptr[1]);
151 }
fv_converter::mixable_weight_manager wm_
jubatus::util::lang::shared_ptr< core::nearest_neighbor::nearest_neighbor_base > nn_
jubatus::util::lang::shared_ptr< fv_converter::datum_to_fv_converter > converter_

Here is the call graph for this function:

Member Data Documentation

jubatus::util::lang::shared_ptr<fv_converter::datum_to_fv_converter> jubatus::core::driver::nearest_neighbor::converter_
private

Definition at line 86 of file nearest_neighbor.hpp.

Referenced by clear(), neighbor_row_from_datum(), set_row(), similar_row(), and unpack().

jubatus::util::lang::shared_ptr<core::nearest_neighbor::nearest_neighbor_base> jubatus::core::driver::nearest_neighbor::nn_
private
jubatus::util::lang::shared_ptr<unlearner::unlearner_base> jubatus::core::driver::nearest_neighbor::unlearner_
private

Definition at line 89 of file nearest_neighbor.hpp.

Referenced by clear(), and set_row().

fv_converter::mixable_weight_manager jubatus::core::driver::nearest_neighbor::wm_
private

Definition at line 90 of file nearest_neighbor.hpp.

Referenced by pack(), and unpack().


The documentation for this class was generated from the following files: