Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot_segment_quality #3

Merged
merged 1 commit into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions analyze_rank_plots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import kde


# load the output of analyze_rank.py, which has different row lengths
textfile = open("quality-est.csv", "r")
listr = textfile.readlines()
textfile.close()
data = np.empty((len(listr)-1,30,))
data[:] = np.nan

i = 0
for line in listr:
if i>0: #do not read first line
lstr = line.strip().split(",")[1:]
data[i-1, :len(lstr)] = np.array([float(v) for v in lstr])[:30]
i+=1


fig = plt.figure()
_, axs = plt.subplots(3,3,figsize=(15,15))

xy = [[0, 2], [2, 4], [2, 6], [2, 8], [2, 10], [2, 12], [2, 14], [2, 16], [2, 18]]
coord = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]
label = [["ogs_kyu_rank", "game_kyu_rank"],["game_kyu_rank", "Move quality of 0 - 50 moves"],["game_kyu_rank", "Move quality of 25 - 75 moves"],["game_kyu_rank", "Move quality of 50 - 100 moves"],["game_kyu_rank", "Move quality of 75 - 125 moves"],["game_kyu_rank", "Move quality of 100 - 150 moves"],["game_kyu_rank", "Move quality of 125 - 175 moves"] ,["game_kyu_rank", "Move quality of 150 - 200 moves"],["game_kyu_rank", "Move quality of 175 - 225 moves"]]

i = 0
for xyel in xy:

x = xyel[0]
y = xyel[1]
plo = data[:, [x, y]][~np.isnan(data[:, [x, y]]).any(axis=1)]


nbins=300
k = kde.gaussian_kde([plo[:, 0],plo[:, 1]])
xi, yi = np.mgrid[-10:30:nbins*1j, -10:30:nbins*1j]
zi = k(np.vstack([xi.flatten(), yi.flatten()]))

axs[coord[i][0]][coord[i][1]].set_aspect('equal', adjustable='box')
axs[coord[i][0]][coord[i][1]].set_xlim(-10, 30)
axs[coord[i][0]][coord[i][1]].set_ylim(-10, 30)
axs[coord[i][0]][coord[i][1]].set_xlabel(label[i][0])
axs[coord[i][0]][coord[i][1]].set_ylabel(label[i][1])
axs[coord[i][0]][coord[i][1]].pcolormesh(xi, yi, zi.reshape(xi.shape), cmap=plt.cm.magma)
axs[coord[i][0]][coord[i][1]].plot([-10, 30], [-10, 30], linewidth=0.5, c='m')
i+=1



plt.tight_layout()
plt.savefig("move_quality.png")
plt.show()

Loading