4

What is the algorithm to tell if I can divide an array of points with a line?

Input: array of (x ,y, TYPE)   # TYPE in (0, 1)
Output: True/False

Or how can I say if it's not possible? When 1 (or more) point is always somewhere in the other group of points.

enter image description here

Sergey
  • 19,487
  • 13
  • 44
  • 68
  • Can't you always? Could you clarify? – cosh Feb 01 '18 at 09:39
  • No, you can have such points that you can't draw a line where left side contains only TYPE 0 points and right side has only TYPE 1 points. – Sergey Feb 01 '18 at 09:41
  • 5
    Construct convex hulls separately for type1 and type2 points and check if they intersect. – n. m. could be an AI Feb 01 '18 at 09:48
  • The second example is lineary separable in *polar coordinates* – Dmitry Bychenko Feb 01 '18 at 10:06
  • 2
    Possible duplicate of [Determine whether the two classes are linearly separable (algorithmically in 2D)](https://stackoverflow.com/questions/9779179/determine-whether-the-two-classes-are-linearly-separable-algorithmically-in-2d) – AakashM Feb 01 '18 at 10:35

1 Answers1

0

Here are some crazy ideas:

  • Build a "convex hull" for every point set (see for example https://en.wikipedia.org/wiki/Graham_scan). And then check if that two convex hulls intersecting or not. If not intersecting than (fairly, i'm not sure) the answer is YES (the separating line exists).

  • Use simplest neural network with single neuron (perceptron). It does exactly the needed task - do linear separaton of two sets. The decision of separation line existance can be made by network error function value on the given set of points.