20 #include <boost/range/adaptor/transformed.hpp>
21 #include <boost/range/algorithm/copy.hpp>
29 using coordinate_t = int;
30 using result_t = double;
31 using point_coordinates_t = std::vector<coordinate_t>;
32 using training_point_t = std::tuple<point_coordinates_t, result_t>;
37 const std::vector<training_point_t> training_points = {
38 training_point_t{{0, 0}, 0.0}, training_point_t{{0, 1}, 0.4},
39 training_point_t{{1, 0}, 0.6}, training_point_t{{1, 1}, 1.0}};
40 const std::vector<point_coordinates_t> test_points =
43 auto const passes = 50;
44 auto const dimensions = std::get<0>(training_points.front()).size();
45 auto const hash_functions_per_point = 1;
48 training_points | boost::adaptors::transformed(get_coordinates),
49 training_points | boost::adaptors::transformed(get_result),
52 hash_functions_per_point);
54 std::vector<result_t> results;
55 results.reserve(test_points.size());
56 model.test(test_points, std::back_inserter(results));
58 std::cout <<
"Solution:" << std::endl;
59 boost::copy(results, std::ostream_iterator<double>(std::cout,
","));
60 std::cout << std::endl;
Factory class for projection_hash_function.
int main()
[LSH Nearest Neighbors Regression Efficient Example]
auto make_lsh_nearest_neighbors_regression_tuple_hash(TrainingPoints &&training_points, TrainingResults &&training_results, unsigned passes, FunctionGenerator &&function_generator, unsigned hash_functions_per_point, unsigned threads_count=std::thread::hardware_concurrency())
This is the special version of make_lsh_nearest_neighbors_regression. This version assumes that hash ...
This file contains set of simple useful functors or functor adapters.
functor for std::tuple::get<I>