import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC
from sklearn.datasets import make_blobs, make_gaussian_quantiles, make_moons, make_circles, make_classification
from ClassificationPlotter import plot_regions
from ipywidgets import *
np.random.seed(1)
X1, y1 = make_blobs(n_samples=100, centers=2, cluster_std=2)
X1[0,:] = [-4, -5]
X1[1,:] = [-6, 7]
plt.figure(figsize = [8,6])
plt.scatter(X1[:, 0], X1[:, 1], c=y1, s=80, edgecolor='k', cmap='rainbow')
plt.show()
%run -i Snippets/snippet10.py
mod_01 = SVC(kernel='linear', C=0.01)
mod_01.fit(X1, y1)
print('Training Accuracy:', mod_01.score(X1, y1))
np.random.seed(3158)
X2_temp, y2 = make_circles(n_samples=100, noise=0.2, factor=0.05)
X2 = np.array([2 * X2_temp[:,0] + 6 * X2_temp[:,1],
2 * X2_temp[:,0] - 3 * X2_temp[:,1]]).T
plt.figure(figsize = [8,6])
plt.scatter(X2[:,0], X2[:,1], c=y2, s=50, edgecolor='k', cmap='rainbow')
plt.show()
%run -i Snippets/snippet11.py
mod_02 = SVC(kernel='poly', degree=2, C=20, gamma='auto')
mod_02.fit(X2, y2)
print('Training Accuracy:', mod_02.score(X2, y2))
sd = np.random.choice(range(9999))
print(sd)
np.random.seed(159)
X3, y3 = make_moons(n_samples=100, noise=0.1)
plt.figure(figsize = [8,6])
plt.scatter(X3[:, 0], X3[:, 1], marker='o', c=y3, s=50, edgecolor='k', cmap='rainbow')
plt.show()
%run -i Snippets/snippet12.py
mod_03 = SVC(kernel='poly', degree=7, C=100, gamma='auto')
mod_03.fit(X3, y3)
print('Training Accuracy:', mod_03.score(X3, y3))