Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine whether the two classes are linearly separable (algorithmically in 2D)

There are two classes, let's call them X and O. A number of elements belonging to these classes are spread out in the xy-plane. Here is an example where the two classes are not linearly separable. It is not possible to draw a straight line that perfectly divides the Xs and the Os on each side of the line.

Members of two classes spread out on the xy-plane

How to determine, in general, whether the two classes are linearly separable?. I am interested in an algorithm where no assumptions are made regarding the number of elements or their distribution. An algorithm of the lowest computational complexity is of course preferred.

like image 408
Håvard Geithus Avatar asked Mar 19 '12 22:03

Håvard Geithus


People also ask

What is the solution if two classes are not linearly separable?

If the data is not linear-separable, a kernel function is used.

What do you mean by linearly separable classification problem give examples?

In two dimensions, that means that there is a line which separates points of one class from points of the other class. EDIT: for example, in this image, if blue circles represent points from one class and red circles represent points from the other class, then these points are linearly separable.

Which is not linearly separable?

Examples. Notice that three points which are collinear and of the form "+ ⋅⋅⋅ — ⋅⋅⋅ +" are also not linearly separable.


1 Answers

If you found the convex hull for both the X points and the O points separately (i.e. you have two separate convex hulls at this stage) you would then just need to check whether any segments of the hulls intersected or whether either hull was enclosed by the other.

If the two hulls were found to be totally disjoint the two data-sets would be geometrically separable.

Since the hulls are convex by definition, any separator would be a straight line.

There are efficient algorithms that can be used both to find the convex hull (the qhull algorithm is based on an O(nlog(n)) quickhull approach I think), and to perform line-line intersection tests for a set of segments (sweepline at O(nlog(n))), so overall it seems that an efficient O(nlog(n)) algorithm should be possible.

This type of approach should also generalise to general k-way separation tests (where you have k groups of objects) by forming the convex hull and performing the intersection tests for each group.

It should also work in higher dimensions, although the intersection tests would start to become more challenging...

Hope this helps.

like image 126
Darren Engwirda Avatar answered Oct 26 '22 12:10

Darren Engwirda