jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
Functions
classifier_test_util.hpp File Reference
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <cfloat>
#include <string>
#include <utility>
#include <vector>
#include "jubatus/util/math/random.h"
Include dependency graph for classifier_test_util.hpp:

Go to the source code of this file.

Functions

std::pair< std::string, std::vector< double > > gen_random_data (jubatus::util::math::random::mtrand &rand)
 
std::pair< std::string, std::vector< double > > gen_random_data3 (jubatus::util::math::random::mtrand &rand)
 
void make_random (jubatus::util::math::random::mtrand &rand, float mu, float sigma, size_t dim, std::vector< double > &v)
 
void make_random (jubatus::util::math::random::mtrand &rand, const std::vector< float > &mus, float sigma, size_t dim, std::vector< double > &v)
 

Function Documentation

std::pair<std::string, std::vector<double> > gen_random_data ( jubatus::util::math::random::mtrand &  rand)

Definition at line 54 of file classifier_test_util.hpp.

References make_random().

55  {
56  const float mu_pos = 1.0;
57  const float mu_neg = -1.0;
58  const float sigma = 1.5;
59  const size_t dim = 10;
60 
61  float mu;
62  std::pair<std::string, std::vector<double> > p;
63  if (rand() % 2 == 0) {
64  p.first = "OK";
65  mu = mu_pos;
66  } else {
67  p.first = "NG";
68  mu = mu_neg;
69  }
70  make_random(rand, mu, sigma, dim, p.second);
71  return p;
72 }
void make_random(jubatus::util::math::random::mtrand &rand, float mu, float sigma, size_t dim, std::vector< double > &v)

Here is the call graph for this function:

std::pair<std::string, std::vector<double> > gen_random_data3 ( jubatus::util::math::random::mtrand &  rand)

Definition at line 74 of file classifier_test_util.hpp.

References make_random().

75  {
76  const char* labels[] = { "1", "2", "3" };
77  std::vector<float> mus;
78  mus.push_back(3);
79  mus.push_back(0);
80  mus.push_back(-3);
81 
82  const float sigma = 1.0;
83  const size_t dim = 10;
84 
85  std::pair<std::string, std::vector<double> > p;
86  size_t l = rand() % 3;
87  p.first = labels[l];
88  std::rotate(mus.begin(), mus.begin() + l, mus.end());
89  make_random(rand, mus, sigma, dim, p.second);
90  return p;
91 }
void make_random(jubatus::util::math::random::mtrand &rand, float mu, float sigma, size_t dim, std::vector< double > &v)

Here is the call graph for this function:

void make_random ( jubatus::util::math::random::mtrand &  rand,
float  mu,
float  sigma,
size_t  dim,
std::vector< double > &  v 
)

Definition at line 30 of file classifier_test_util.hpp.

Referenced by gen_random_data(), and gen_random_data3().

35  {
36  for (size_t i = 0; i < dim; i++) {
37  float value = rand.next_gaussian(mu, sigma);
38  v.push_back(value);
39  }
40 }
std::vector< T > v(size)

Here is the caller graph for this function:

void make_random ( jubatus::util::math::random::mtrand &  rand,
const std::vector< float > &  mus,
float  sigma,
size_t  dim,
std::vector< double > &  v 
)

Definition at line 42 of file classifier_test_util.hpp.

47  {
48  for (size_t i = 0; i < dim; i++) {
49  float value = rand.next_gaussian(mus[i % mus.size()], sigma);
50  v.push_back(value);
51  }
52 }
std::vector< T > v(size)