SG++
Nearest Neighbors

This example calculates all feature-interactions that arise from an image with 64 pixels, when one only considers pixels whose \( L_2 \) distance is not larger than \( \sqrt{2} \).

int main(void) {

First create the neighbors of all pixels.

const auto neigh = sgpp::datadriven::NearestNeighbors(8, 8);

Then create all arising interaction terms up to an order of 3.

const auto combs = neigh.getAllInteractions(3, std::sqrt(2));
for (const auto& comb : combs) {
for (const auto term : comb) {
std::cout << term << ' ';
}