I have 2 lists RED and BLUE in the form of (x,y) tuples and a list of line equations in the form of ax+by+c. My requirement is to extract the coefficients from each line equation and determine based on the plots for the 2 set of points whether the points are clearly separated on both sides of the line. Challenge is that I cannot use numpy.
My approach has been to zip the 2 lists RED and BLUE points using pyplot. Now I am trying to extract the coefficients using regular expression as below.
lines = ["1x+1y+0","1x-1y+0","1x+0y-3","0x+1y-0.5"]
for i in lines:
z = re.match('(\d+)?(x)?\+(\d+)?(y)?\+(\d)?', i)
However, Im not able to use 'z' as it is of 'NoneType'. Even if I am able to use it somehow, I am not sure how to use the intercept and slope to determine that the RED and BLUE points are on either side of the line.
Any pointers are hugely appreciated.
Tried plotting the points using matplotlib
Red_x = [(x,y) for x,y in Red]
Blue_x = [(x,y) for x,y in Blue]
plt.plot(*zip(*Red_x),'or')
plt.scatter(*zip(*Blue_x))