All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
Public Member Functions | List of all members
paal::lsh_nearest_neighbors_regression< HashValue, LshFun, HashForHashValue > Class Template Reference

detail More...

#include <lsh_nearest_neighbors_regression.hpp>

Public Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 serialization
 
 lsh_nearest_neighbors_regression ()=default
 default constructor, only for serialization purpose
 
template<typename TrainingPoints , typename TrainingResults , typename LshFunctionGenerator >
 lsh_nearest_neighbors_regression (TrainingPoints &&training_points, TrainingResults &&training_results, unsigned passes, LshFunctionGenerator &&lsh_function_generator, unsigned threads_count=std::thread::hardware_concurrency())
 initializes model and trainings model using training points and results More...
 
bool operator== (lsh_nearest_neighbors_regression const &other) const
 operator==
 
template<typename TrainingPoints , typename TrainingResults >
void update (TrainingPoints &&training_points, TrainingResults &&training_results, unsigned threads_count=std::thread::hardware_concurrency())
 trainings model More...
 
template<typename TestPoints , typename OutputIterator >
void test (TestPoints &&test_points, OutputIterator result) const
 queries model, does not heave threads_count parameter, because this is much more natural to do from outside of the function More...
 

Detailed Description

template<typename HashValue, typename LshFun, typename HashForHashValue = range_hash>
class paal::lsh_nearest_neighbors_regression< HashValue, LshFun, HashForHashValue >

detail

For each test point counts average result of training points with hash equal to test point's hash, basing on Locality-sensitve hashing.

Example:

#include <boost/numeric/ublas/vector.hpp>
#include <boost/range/algorithm/copy.hpp>
#include <iostream>
#include <iterator>
#include <vector>
using coordinate_t = int;
using point_t = boost::numeric::ublas::vector<coordinate_t>;
auto make_point(const std::initializer_list<int> &list) {
point_t point(list.size());
boost::copy(list, point.begin());
return point;
};
int main() {
const std::vector<point_t> training_points =
{make_point({0, 0}), make_point({0, 1}),
make_point({1, 0}), make_point({1, 1})};
const std::vector<double> training_results = {0.0, 0.4, 0.6, 1.0};
const std::vector<point_t> test_points =
{make_point({0, -1}), make_point({2, 1})};
auto const passes = 50;
auto const hash_functions_per_point = 10;
auto const dimensions = training_points.front().size();
auto const threads_count = 1;
//w_param should be essentially bigger than radius of expected test point neighborhood
auto const w_param = 3.0;
auto lsh_function_generator =
training_points, training_results,
passes,
std::move(lsh_function_generator),
hash_functions_per_point,
threads_count);
std::vector<double> results;
model.test(test_points, std::back_inserter(results));
std::cout << "Solution:" << std::endl;
boost::copy(results, std::ostream_iterator<double>(std::cout, ","));
std::cout << std::endl;
return 0;
}

example file is lsh_nearest_neighbors_regression_example.cpp

Template Parameters
HashValuereturn type of functions generated by LshFunctionGenerator object
LshFunctionGeneratortype of functor which generates proper LSH functions
HashForHashValuehash type to be used in hash maps

Definition at line 194 of file lsh_nearest_neighbors_regression.hpp.

Constructor & Destructor Documentation

template<typename HashValue, typename LshFun, typename HashForHashValue = range_hash>
template<typename TrainingPoints , typename TrainingResults , typename LshFunctionGenerator >
paal::lsh_nearest_neighbors_regression< HashValue, LshFun, HashForHashValue >::lsh_nearest_neighbors_regression ( TrainingPoints &&  training_points,
TrainingResults &&  training_results,
unsigned  passes,
LshFunctionGenerator &&  lsh_function_generator,
unsigned  threads_count = std::thread::hardware_concurrency() 
)
inline

initializes model and trainings model using training points and results

Template Parameters
TrainingPoints
TrainingResults
Parameters
training_points
training_results
passesnumber of used LSH functions
lsh_function_generatorfunctor generating proper LSH functions
threads_count

Definition at line 233 of file lsh_nearest_neighbors_regression.hpp.

Member Function Documentation

template<typename HashValue, typename LshFun, typename HashForHashValue = range_hash>
template<typename TestPoints , typename OutputIterator >
void paal::lsh_nearest_neighbors_regression< HashValue, LshFun, HashForHashValue >::test ( TestPoints &&  test_points,
OutputIterator  result 
) const
inline

queries model, does not heave threads_count parameter, because this is much more natural to do from outside of the function

Template Parameters
TestPoints
OutputIterator
Parameters
test_points
result

Definition at line 292 of file lsh_nearest_neighbors_regression.hpp.

template<typename HashValue, typename LshFun, typename HashForHashValue = range_hash>
template<typename TrainingPoints , typename TrainingResults >
void paal::lsh_nearest_neighbors_regression< HashValue, LshFun, HashForHashValue >::update ( TrainingPoints &&  training_points,
TrainingResults &&  training_results,
unsigned  threads_count = std::thread::hardware_concurrency() 
)
inline

trainings model

Template Parameters
TrainingPoints
TrainingResults
Parameters
training_points
training_results
threads_count

Definition at line 267 of file lsh_nearest_neighbors_regression.hpp.


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