Created
July 14, 2021 01:30
-
-
Save JustinSDK/4e67ccd8d02eeafc3f81fb022274799d to your computer and use it in GitHub Desktop.
雙拋物面提升維度
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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