For each test point counts average result of training points with hash equal to test point's hash, basing on Locality-sensitve hashing.
#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;
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;
}