You can download the dataset directly but you can also fetch it via:
wget https://calmcode.io/datasets/drawndata2.csv
Here's what the original dataset looks like.
df = pd.read_csv("drawndata2.csv")
X = df[['x', 'y']].values
y = df['z'] == 'a'
plt.scatter(X[:, 0], X[:, 1], c=y);
Here's the PolynomialFeatures
at work.
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import Pipeline
pipe = Pipeline([
("scale", PolynomialFeatures()),
("model", LogisticRegression())
])
pred = pipe.fit(X, y).predict(X)
plt.scatter(X[:, 0], X[:, 1], c=pred);