<jupyter_start><jupyter_text>Non-Linear Classification- In many real life problems, the data is not linearly separable,but we need to classify the data. This can be done using by projecting the data to higer dimesions so that it becomes linearly separable.      Projecting data to higher dimensions!When working with non-linear datasets, we can project orginal feature vectors into higher dimensional space where they can be linearly separated!   Let us see one exampleData in 2-Dimensional SpaceData Projected in 3-D Dimensional Space, after processing the original data using a non-linear function.  Code<jupyter_code>from sklearn.datasets import make_circles
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
X,Y  = make_circles(n_samples=500,noise=0.02)
print(X.shape,Y.shape)
styles = plt.style.available
plt.style.use(styles[4])

plt.scatter(X[:,0],X[:,1],c=Y)
plt.show()
def phi(X):
    """Non Linear transformation on X"""
    X1 = X[:,0]
    X2 = X[:,1]
    X3 = (X1**2 + X2**2)
    
    X_ = np.zeros((X.shape[0],X.shape[1]+1))
    print(X_.shape)
    X_[:,:-1] = X
    X_[:,-1] = X3
    return X_  

X_ = phi(X)
print(X[:3,:])
print(X_[:3,:])<jupyter_output>[[ 0.0224355  -0.81710442  0.66816299]
 [-0.04268384 -0.77868313  0.60816933]
 [ 0.72010927  0.68572168  0.98877158]]
{'fraction_non_alphanumeric': 0.11861861861861862, 'fraction_numerical': 0.08258258258258258, 'mean_word_length': 4.20703125, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '326967', 'license': 'MIT', 'n_tokens_mistral': 537, 'n_tokens_neox': 480, 'n_words': 146, 'path': '14. Support Vector Machines/.ipynb_checkpoints/Non-linear Classification-checkpoint.ipynb', 'repo_name': 'sgeek28/Data-Science', 'size': '1332'}