3.5.1 선형적으로 구분되지 않는 데이터를 위한 커널 방법

    다음 코드에서 넘파이 logical_xor 함수를 사용하여 XOR 형태의 간단한 데이터셋을 만듭니다. 대략 100개의 샘플은 클래스 레이블 1로 할당되고 나머지 100개의 샘플은 클래스 레이블 -1로 할당될 것입니다.

    >>> import matplotlib.pyplot as plt
    >>> import numpy as np
    >>> np.random.seed(1)
    >>> X_xor = np.random.randn(200, 2)
    >>> y_xor = np.logical_xor(X_xor[:, 0] > 0,
    ...                        X_xor[:, 1] > 0)
    >>> y_xor = np.where(y_xor, 1, -1)
    >>> plt.scatter(X_xor[y_xor == 1, 0],
    ...             X_xor[y_xor == 1, 1],
    ...             c='b', marker='x',
    ...             label='1')
    >>> plt.scatter(X_xor[y_xor == -1, 0],
    ...             X_xor[y_xor == -1, 1],
    ...             c='r',
    ...             marker='s',
    ...             label='-1')
    >>> plt.xlim([-3, 3])
    >>> plt.ylim([-3, 3])
    >>> plt.legend(loc='best')
    >>> plt.tight_layout()
    >>> plt.show()
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.