Last active
June 18, 2018 03:19
-
-
Save ychennay/65a6498531176a50418a9d5f2fcaaa8e 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
X = np.array([[0, 0]]) | |
y = np.array([[1.2]]) | |
gp = GaussianProcess(X, y) | |
gp.update([[1.5, -1.5]], [[2.3]]) # second data point | |
gp.update([[-2,1.5]], [[-1.0]]) # third data point | |
gp.update([[2.1,1.3]], [[-0.6]]) # fourth data point | |
delta = 0.05 # changes granularity of the contour map | |
x = np.arange(-3.0, 3.0, delta) | |
y = np.arange(-2.0, 2.0, delta) | |
X, Y = np.meshgrid(x, y) | |
Z = [] | |
for i in x: | |
for j in y: | |
# I take only the 0th (first) element since that is the prediction | |
# The second element is the uncertainty | |
Z.append(gp.new_predict([[i,j]])[0]) | |
results = np.array([Z]).reshape(len(x), len(y)) | |
plt.figure() | |
CS = plt.contourf(X, Y, results.T, cmap='RdYlBu') | |
plt.colorbar() | |
for data in gp.X: | |
plt.scatter(data[0], data[1], c="g") | |
plt.title("Contour Map of Steph Curry's Scoring \n After 4 Data Points (Games)") | |
plt.xlabel("Free Throws") | |
plt.ylabel("Turnovers") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment