Skip to content

Instantly share code, notes, and snippets.

@JustinSDK
Created July 14, 2021 01:30
Show Gist options
  • Save JustinSDK/4e67ccd8d02eeafc3f81fb022274799d to your computer and use it in GitHub Desktop.
Save JustinSDK/4e67ccd8d02eeafc3f81fb022274799d to your computer and use it in GitHub Desktop.
雙拋物面提升維度
import numpy as np
import matplotlib.pyplot as plt
# 雙抛物面公式
def f(x, y):
return x ** 2 / 4 - y ** 2 / 4
# https://openhome.cc/Gossip/DCHardWay/ab.csv
data = np.loadtxt('ab.csv', delimiter=',')
a = data[:,0]
b = data[:,1]
c = f(a, b)
label = data[:,2]
zero = label == 0
one = label == 1
ax = plt.axes(projection='3d')
ax.set_xlabel('a')
ax.set_ylabel('b')
ax.set_zlabel('c')
ax.set_box_aspect((1, 1, 1))
ax.scatter(a[zero], b[zero], c[zero], marker = 'o')
ax.scatter(a[one], b[one], c[one], marker = 'x')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment