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

#include <keyword_weights.hpp>

Collaboration diagram for jubatus::core::fv_converter::keyword_weights:
Collaboration graph

Public Member Functions

void add_weight (const std::string &key, float weight)
 
void clear ()
 
uint64_t get_document_count () const
 
size_t get_document_frequency (const std::string &key) const
 
float get_user_weight (const std::string &key) const
 
 keyword_weights ()
 
void merge (const keyword_weights &w)
 
 MSGPACK_DEFINE (document_count_, document_frequencies_, weights_)
 
std::string to_string () const
 
void update_document_frequency (const common::sfv_t &fv)
 

Private Types

typedef jubatus::util::data::unordered_map< std::string, float > weight_t
 

Private Member Functions

double get_global_weight (const std::string &key) const
 

Private Attributes

uint64_t document_count_
 
counter< std::string > document_frequencies_
 
weight_t weights_
 

Detailed Description

Definition at line 30 of file keyword_weights.hpp.

Member Typedef Documentation

typedef jubatus::util::data::unordered_map<std::string, float> jubatus::core::fv_converter::keyword_weights::weight_t
private

Definition at line 61 of file keyword_weights.hpp.

Constructor & Destructor Documentation

jubatus::core::fv_converter::keyword_weights::keyword_weights ( )

Member Function Documentation

void jubatus::core::fv_converter::keyword_weights::add_weight ( const std::string &  key,
float  weight 
)

Definition at line 57 of file keyword_weights.cpp.

References weights_.

Referenced by jubatus::core::fv_converter::weight_manager::add_weight().

57  {
58  weights_[key] = weight;
59 }

Here is the caller graph for this function:

void jubatus::core::fv_converter::keyword_weights::clear ( )
uint64_t jubatus::core::fv_converter::keyword_weights::get_document_count ( ) const
inline

Definition at line 40 of file keyword_weights.hpp.

References document_count_.

Referenced by jubatus::core::fv_converter::weight_manager::get_document_count().

40  {
41  return document_count_;
42  }

Here is the caller graph for this function:

size_t jubatus::core::fv_converter::keyword_weights::get_document_frequency ( const std::string &  key) const
inline

Definition at line 36 of file keyword_weights.hpp.

References document_frequencies_.

Referenced by jubatus::core::fv_converter::weight_manager::get_document_frequency().

36  {
37  return document_frequencies_[key];
38  }

Here is the caller graph for this function:

double jubatus::core::fv_converter::keyword_weights::get_global_weight ( const std::string &  key) const
private
float jubatus::core::fv_converter::keyword_weights::get_user_weight ( const std::string &  key) const

Definition at line 61 of file keyword_weights.cpp.

References weights_.

Referenced by jubatus::core::fv_converter::weight_manager::get_user_weight().

61  {
62  weight_t::const_iterator wit = weights_.find(key);
63  if (wit != weights_.end()) {
64  return wit->second;
65  } else {
66  return 0;
67  }
68 }

Here is the caller graph for this function:

void jubatus::core::fv_converter::keyword_weights::merge ( const keyword_weights w)

Definition at line 70 of file keyword_weights.cpp.

References jubatus::core::fv_converter::counter< T >::add(), document_count_, document_frequencies_, and weights_.

Referenced by jubatus::core::fv_converter::versioned_weight_diff::merge(), jubatus::core::fv_converter::weight_manager::mix(), and jubatus::core::fv_converter::weight_manager::put_diff().

70  {
71  document_count_ += w.document_count_;
72  document_frequencies_.add(w.document_frequencies_);
73  weight_t weights(w.weights_);
74  weights.insert(weights_.begin(), weights_.end());
75  weights_.swap(weights);
76 }
jubatus::util::data::unordered_map< std::string, float > weight_t
void add(const counter< T > &counts)
Definition: counter.hpp:79

Here is the call graph for this function:

Here is the caller graph for this function:

jubatus::core::fv_converter::keyword_weights::MSGPACK_DEFINE ( document_count_  ,
document_frequencies_  ,
weights_   
)
string jubatus::core::fv_converter::keyword_weights::to_string ( ) const

Definition at line 84 of file keyword_weights.cpp.

References document_count_, document_frequencies_, and weights_.

Referenced by jubatus::core::fv_converter::weight_manager::to_string().

84  {
85  stringstream ss;
86  ss << "document_count: " << document_count_
87  << " document_frequencies: " << document_frequencies_
88  << " weights: {";
89  for (weight_t::const_iterator it = weights_.begin();
90  it != weights_.end();
91  ++it) {
92  ss << it->first << " => " << it->second << std::endl;
93  }
94  ss << " }";
95  return ss.str();
96 }

Here is the caller graph for this function:

void jubatus::core::fv_converter::keyword_weights::update_document_frequency ( const common::sfv_t fv)

Definition at line 50 of file keyword_weights.cpp.

References document_count_, and document_frequencies_.

Referenced by jubatus::core::fv_converter::weight_manager::update_weight().

50  {
52  for (sfv_t::const_iterator it = fv.begin(); it != fv.end(); ++it) {
53  ++document_frequencies_[it->first];
54  }
55 }

Here is the caller graph for this function:

Member Data Documentation

uint64_t jubatus::core::fv_converter::keyword_weights::document_count_
private
counter<std::string> jubatus::core::fv_converter::keyword_weights::document_frequencies_
private
weight_t jubatus::core::fv_converter::keyword_weights::weights_
private

Definition at line 62 of file keyword_weights.hpp.

Referenced by add_weight(), clear(), get_user_weight(), merge(), and to_string().


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