19 #include <boost/numeric/ublas/vector.hpp>
20 #include <boost/range/algorithm/copy.hpp>
26 using coordinate_t = int;
27 using point_t = boost::numeric::ublas::vector<coordinate_t>;
29 auto make_point(
const std::initializer_list<int> &list) {
30 point_t point(list.size());
31 boost::copy(list, point.begin());
36 const std::vector<point_t> training_points =
37 {make_point({0, 0}), make_point({0, 1}),
38 make_point({1, 0}), make_point({1, 1})};
39 const std::vector<double> training_results = {0.0, 0.4, 0.6, 1.0};
40 const std::vector<point_t> test_points =
41 {make_point({0, -1}), make_point({2, 1})};
43 auto const passes = 50;
44 auto const hash_functions_per_point = 10;
45 auto const dimensions = training_points.front().size();
46 auto const threads_count = 1;
48 auto const w_param = 3.0;
50 auto lsh_function_generator =
53 training_points, training_results,
55 std::move(lsh_function_generator),
56 hash_functions_per_point,
59 std::vector<double> results;
60 model.test(test_points, std::back_inserter(results));
62 std::cout <<
"Solution:" << std::endl;
63 boost::copy(results, std::ostream_iterator<double>(std::cout,
","));
64 std::cout << std::endl;
Factory class for l_p_hash_function.
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 ...