jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
Classes | Typedefs | Functions | Variables
jubatus::core::recommender Namespace Reference

Classes

class  euclid_lsh
 
class  inverted_index
 
class  lsh
 
class  minhash
 
class  nearest_neighbor_recommender
 
class  recommender_base
 
class  recommender_factory
 
class  recommender_mock
 
class  recommender_mock_storage
 

Typedefs

typedef storage::lsh_index_storage lsh_index_storage
 
typedef framework::linear_mixable_helper< recommender_mock_storage, recommender_mock_storagemixable_recommender_mock_storage
 
typedef storage::mixable_lsh_index_storage::model_ptr model_ptr
 
typedef core::common::sfv_t sfv_diff_t
 

Functions

void generate_random_vector (size_t dim, uint32_t seed, std::vector< float > &v)
 
void generate_random_vector (size_t dim, uint32_t seed, vector< float > &ret)
 
std::vector< std::pair< std::string, float > > make_ids (const std::string &repr)
 
vector< pair< string, float > > make_ids (const string &repr)
 
common::sfv_t make_sfv (const std::string &repr)
 
common::sfv_t make_sfv (const string &repr)
 
void prod_invert_and_vector (const jubatus::util::data::unordered_map< std::string, std::vector< float > > &matrix, const common::sfv_t &vec, size_t dim, std::vector< float > &ret)
 
void prod_invert_and_vector (const unordered_map< string, vector< float > > &matrix, const common::sfv_t &vec, size_t dim, vector< float > &ret)
 
void set_bit_vector (const std::vector< float > &vec, jubatus::core::storage::bit_vector &bit_vec)
 
void set_bit_vector (const std::vector< float > &vec, bit_vector &bit_vec)
 

Variables

static const uint64_t DEFAULT_HASH_NUM = 64
 

Typedef Documentation

Definition at line 91 of file euclid_lsh.cpp.

Definition at line 97 of file recommender_mock_storage.hpp.

Definition at line 90 of file euclid_lsh.cpp.

Definition at line 26 of file recommender_type.hpp.

Function Documentation

void jubatus::core::recommender::generate_random_vector ( size_t  dim,
uint32_t  seed,
std::vector< float > &  v 
)
void jubatus::core::recommender::generate_random_vector ( size_t  dim,
uint32_t  seed,
vector< float > &  ret 
)

Definition at line 35 of file lsh_util.cpp.

References jubatus::core::common::jsonconfig::v().

Referenced by jubatus::core::recommender::lsh::generate_column_base().

35  {
36  jubatus::util::math::random::mtrand rnd(seed);
37  vector<float> v(dim);
38  for (uint64_t i = 0; i < dim; ++i) {
39  v[i] = rnd.next_gaussian();
40  }
41  ret.swap(v);
42 }
std::vector< T > v(size)

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector<std::pair<std::string, float> > jubatus::core::recommender::make_ids ( const std::string &  repr)
vector<pair<string, float> > jubatus::core::recommender::make_ids ( const string &  repr)

Definition at line 45 of file recommender_mock_util.cpp.

References make_sfv().

45  {
46  return make_sfv(repr);
47 }
common::sfv_t make_sfv(const string &repr)

Here is the call graph for this function:

common::sfv_t jubatus::core::recommender::make_sfv ( const std::string &  repr)
common::sfv_t jubatus::core::recommender::make_sfv ( const string &  repr)

Definition at line 33 of file recommender_mock_util.cpp.

Referenced by make_ids().

33  {
34  vector<string> elems = split(repr, ' ');
35  common::sfv_t sfv(elems.size());
36  for (size_t i = 0; i < elems.size(); ++i) {
37  vector<string> parts = split(elems[i], ':');
38  sfv[i] = make_pair(
39  parts[0],
40  jubatus::util::lang::lexical_cast<float>(parts[1]));
41  }
42  return sfv;
43 }
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29

Here is the caller graph for this function:

void jubatus::core::recommender::prod_invert_and_vector ( const jubatus::util::data::unordered_map< std::string, std::vector< float > > &  matrix,
const common::sfv_t vec,
size_t  dim,
std::vector< float > &  ret 
)
void jubatus::core::recommender::prod_invert_and_vector ( const unordered_map< string, vector< float > > &  matrix,
const common::sfv_t vec,
size_t  dim,
vector< float > &  ret 
)

Definition at line 55 of file lsh_util.cpp.

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

Referenced by jubatus::core::recommender::lsh::calc_lsh_values().

59  {
60  vector<float> r(dim);
61  for (size_t i = 0; i < vec.size(); ++i) {
62  const string& column = vec[i].first;
63  float val = vec[i].second;
64  unordered_map<string, vector<float> >::const_iterator it =
65  matrix.find(column);
66  if (it == matrix.end()) {
67  continue;
68  }
69  const vector<float>& v = it->second;
70 
71  JUBATUS_ASSERT_EQ(v.size(), r.size(), "");
72  for (size_t j = 0; j < v.size(); ++j) {
73  r[j] += v[j] * val;
74  }
75  }
76 
77  ret.swap(r);
78 }
#define JUBATUS_ASSERT_EQ(a, b, messages)
Definition: assert.hpp:63
std::vector< T > v(size)

Here is the call graph for this function:

Here is the caller graph for this function:

void jubatus::core::recommender::set_bit_vector ( const std::vector< float > &  vec,
jubatus::core::storage::bit_vector bit_vec 
)
void jubatus::core::recommender::set_bit_vector ( const std::vector< float > &  vec,
bit_vector &  bit_vec 
)

Definition at line 44 of file lsh_util.cpp.

References jubatus::core::storage::bit_vector_base< bit_base >::resize_and_clear().

Referenced by jubatus::core::recommender::lsh::calc_lsh_values().

44  {
45  bit_vector bv;
46  bv.resize_and_clear(vec.size());
47  for (size_t i = 0; i < vec.size(); ++i) {
48  if (vec[i] >= 0.f) {
49  bv.set_bit(i);
50  }
51  }
52  bit_vec.swap(bv);
53 }
void resize_and_clear(uint64_t bit_num)
Definition: bit_vector.hpp:174
bit_vector_base< uint64_t > bit_vector

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const uint64_t jubatus::core::recommender::DEFAULT_HASH_NUM = 64
static

Definition at line 38 of file lsh.cpp.