def plot_surface(gr, ax, keys, imshow=False): # from https://github.com/russelljjarvis/neuronunit/blob/dev/neuronunit/unit_test/progress_report_4thJuly.ipynb # Not rendered https://github.com/russelljjarvis/neuronunit/blob/dev/neuronunit/unit_test/progress_report_.ipynb gr = [g for g in gr if type(g.dtc) is not type(None)] gr = [g for g in gr if type(g.dtc.scores) is not type(None)] ax.cla() gr_ = [] index = 0 for i, g in enumerate(gr): if type(g.dtc) is not type(None): gr_.append(g) else: index = i xx = np.array([p.dtc.attrs[str(keys[0])] for p in gr]) yy = np.array([p.dtc.attrs[str(keys[1])] for p in gr]) zz = np.array([np.sum(list(p.dtc.scores.values())) for p in gr]) dim = len(xx) N = int(np.sqrt(len(xx))) X = xx.reshape((N, N)) Y = yy.reshape((N, N)) Z = zz.reshape((N, N)) if imshow == False: ax.pcolormesh(X, Y, Z, edgecolors='black') else: import seaborn as sns sns.set() ax = sns.heatmap(Z) ax.set_title(' {0} vs {1} '.format(keys[0], keys[1])) return ax
def plot_surface(gr, ax, keys, imshow=False): # from # https://github.com/russelljjarvis/neuronunit/blob/dev/neuronunit/unit_test/progress_report_4thJuly.ipynb # Not rendered # https://github.com/russelljjarvis/neuronunit/blob/dev/neuronunit/unit_test/progress_report_.ipynb gr = [g for g in gr if type(g.dtc) is not type(None)] gr = [g for g in gr if type(g.dtc.scores) is not type(None)] ax.cla() #gr = [ g gr_ = [] index = 0 for i, g in enumerate(gr): if type(g.dtc) is not type(None): gr_.append(g) else: index = i z = [np.sum(list(p.dtc.scores.values())) for p in gr] x = [p.dtc.attrs[str(keys[0])] for p in gr] y = [p.dtc.attrs[str(keys[1])] for p in gr] # impute missings if len(x) != 100: delta = 100 - len(x) for i in range(0, delta): x.append(np.mean(x)) y.append(np.mean(y)) z.append(np.mean(z)) xx = np.array(x) yy = np.array(y) zz = np.array(z) dim = len(xx) N = int(np.sqrt(len(xx))) X = xx.reshape((N, N)) Y = yy.reshape((N, N)) Z = zz.reshape((N, N)) if imshow == False: ax.pcolormesh(X, Y, Z, edgecolors='black') else: import seaborn as sns sns.set() ax = sns.heatmap(Z) #ax.imshow(Z) #ax.pcolormesh(xi, yi, zi, edgecolors='black') ax.set_title(' {0} vs {1} '.format(keys[0], keys[1])) return ax
def plot_surface(gr, ax, keys, constant, imshow=True): # from https://github.com/russelljjarvis/neuronunit/blob/dev/neuronunit/unit_test/progress_report_4thJuly.ipynb # Not rendered https://github.com/russelljjarvis/neuronunit/blob/dev/neuronunit/unit_test/progress_report_.ipynb gr = [g for g in gr if type(g.dtc) is not type(None)] gr = [g for g in gr if type(g.dtc.scores) is not type(None)] ax.cla() gr_ = [] index = 0 for i, g in enumerate(gr): if type(g.dtc) is not type(None): gr_.append(g) else: index = i xx = np.array([p.dtc.attrs[str(keys[0])] for p in gr]) yy = np.array([p.dtc.attrs[str(keys[1])] for p in gr]) zz = np.array([p.dtc.get_ss() for p in gr]) dim = len(xx) N = int(np.sqrt(len(xx))) X = xx.reshape((N, N)) Y = yy.reshape((N, N)) Z = zz.reshape((N, N)) if imshow == True: img = ax.pcolormesh(X, Y, Z, edgecolors='black') #ax.colorbar() else: import seaborn as sns sns.set() current_palette = sns.color_palette() sns.palplot(current_palette) #df = pd.DataFrame(Z, columns=xx) img = sns.heatmap(Z) #,cm=current_palette) #ax.colorbar() ax.set_title(' {0} vs {1} '.format(keys[0], keys[1])) return ax, img