Hi @tbhaxor,
in addition to @rmwkwok 's excellent answer.
I agree: Feature Engineering will do the trick: Of course you can also apply a transformation as we know it from polar coordinates to get rid of the non-linearity in the data and solve the problem with a linear classifier.
import numpy as np
import math
import matplotlib.pyplot as plt
# Some Parameters
dim = 100
noise = 0.2
#Create inner circle
x_1 = np.cos(np.linspace(0,2*math.pi, dim)) + noise*np.random.normal(0, 1, dim)
y_1 = np.sin(np.linspace(0,2*math.pi, dim)) + noise*np.random.normal(0, 1, dim)
#Create outer circle
x_2 = 2*np.cos(np.linspace(0,2*math.pi, dim)) + noise*np.random.normal(0, 1, dim)
y_2 = 2*np.sin(np.linspace(0,2*math.pi, dim)) + noise*np.random.normal(0, 1, dim)
# Plot of Circle data
ax = plt.gca()
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
plt.scatter(x_1,y_1)
plt.scatter(x_2,y_2)
plt.title('Before Transformation')
plt.show()
# Transformation function
def pol_transform(x, y):
alpha = np.sqrt(x*x+y*y)
beta = np.arctan2(y,x)
return(alpha, beta)
# Apply transforation
alpha_1, beta_1 = pol_transform(x_1,y_1)
alpha_2, beta_2 = pol_transform(x_2,y_2)
# Plot of transformed data
ax = plt.gca()
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
plt.scatter(alpha_1,beta_1)
plt.scatter(alpha_2,beta_2)
plt.title('After Transformation')
plt.show()
After transformation, a generalized linear model, like a logistic regression will do the trick to solve this classification.
Best regards
Christian