Skip to content

Instantly share code, notes, and snippets.

@andycasey
Created November 2, 2017 00:37
Show Gist options
  • Select an option

  • Save andycasey/a65e9da155c5760d3afcb74dd67bc687 to your computer and use it in GitHub Desktop.

Select an option

Save andycasey/a65e9da155c5760d3afcb74dd67bc687 to your computer and use it in GitHub Desktop.
import numpy as np
from scipy.spatial import Delaunay
training_set_labels = #.... from somewhere else
test_set_labels = np.atleast_2d(test_set_labels)
# construct convex hull of the training set using all labels
hull = Delaunay(training_set_labels)
# in_convex_hull will give true/false as to whether the test
# set labels fall within the multidimensional convex hull of
# the training set labels.
in_convex_hull = hull.find_simplex(test_set_labels) >= 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment