本文整理汇总了Python中reprep.Report.data方法的典型用法代码示例。如果您正苦于以下问题:Python Report.data方法的具体用法?Python Report.data怎么用?Python Report.data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reprep.Report
的用法示例。
在下文中一共展示了Report.data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: hist_plots
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def hist_plots(d):
# TO
vars = [ ('C', d.C, {}),
('y', cov2corr(d.y_cov, False), {}),
('y_dot', cov2corr(d.y_dot_cov, False), {}),
('y_dot_sign', cov2corr(d.y_dot_sign_cov, False), {}) ]
r = Report()
f = r.figure(cols=5)
for var in vars:
label = var[0]
x = var[1]
nid = "hist_%s" % label
with r.data_pylab(nid) as pylab:
pylab.hist(x.flat, bins=128)
f.sub(nid, 'histogram of correlation of %s' % label)
order = scale_score(x)
r.data('order%s' % label, order).display('posneg').add_to(f, 'ordered')
nid = "hist2_%s" % label
with r.data_pylab(nid) as pylab:
pylab.plot(x.flat, order.flat, '.', markersize=0.2)
pylab.xlabel(label)
pylab.ylabel('order')
f.sub(nid, 'histogram of correlation of %s' % label)
h = create_histogram_2d(d.C, x, resolution=128)
r.data('h2d_%s' % label, numpy.flipud(h.T)).display('scale').add_to(f)
return r
示例2: simple_plots
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def simple_plots(d):
# TO
y_cov = d.y_cov
y_dot_cov = d.y_dot_cov
y_dot_sign_cov = d.y_dot_sign_cov
vars = [ ('y', y_cov, {}),
('y_dot', y_dot_cov, {}),
('y_dot_sign', y_dot_sign_cov, {}) ]
#
# I = numpy.eye(y_cov.shape[0])
#
r = Report()
f = r.figure(cols=3)
for var in vars:
label = var[0]
cov = var[1]
corr = cov2corr(cov, zero_diagonal=False)
corr_z = cov2corr(cov, zero_diagonal=True)
n1 = r.data("cov_%s" % label, cov).display('posneg')
n2 = r.data("corr_%s" % label, corr).display('posneg')
n3 = r.data("corrz_%s" % label, corr_z).display('posneg')
f.sub(n1, 'Covariance of %s' % label)
f.sub(n2, 'Correlation of %s ' % label)
f.sub(n3, 'Correlation of %s (zeroing diagonal)' % label)
return r
示例3: report_statistics
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def report_statistics(id_sub, stats):
records = stats['records']
distance = records['distance']
delta = records['delta']
order = scale_score(distance)
order = order / float(order.size)
r = Report('stats-%s' % id_sub)
r.data('records', records)
f = r.figure()
with f.plot('scatter') as pylab:
pylab.scatter(delta, distance)
pylab.xlabel('delta')
pylab.ylabel('distance')
pylab.axis((-1, np.max(delta) + 1, -0.05, np.max(distance)))
with f.plot('with_stats', **dp_predstats_fig) as pylab:
fancy_error_display(pylab, delta, distance, 'g')
with f.plot('distance_order', **dp_predstats_fig) as pylab:
fancy_error_display(pylab, delta, order, color='k')
f = r.figure(cols=1)
bins = np.linspace(0, np.max(distance), 100)
for i, d in enumerate(set(delta)):
with f.plot('conditional%d' % i) as pylab:
which = delta == d
pylab.hist(distance[which], bins)
return r
示例4: filter_phase_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def filter_phase_report(stats):
P = stats['P']
r = Report('unknown')
f = r.figure()
r.data('P', P.T).display('scale').add_to(f)
return r
示例5: ReprepPublisher
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
class ReprepPublisher(Publisher):
default_max_cols = 5
def __init__(self, rid=None, report=None, cols=default_max_cols):
# TODO: clear up this interface
if report is None:
self.r = Report(rid)
else:
self.r = report
self.cols = cols
self._f = None
def fig(self):
''' Returns reference to current RepRep figure. '''
if self._f is None:
self._f = self.r.figure(cols=self.cols)
return self._f
@contract(name='str', value='array', caption='None|str')
def array(self, name, value, caption=None): # XXX to change
self.r.data(name, value, mime=MIME_PYTHON, caption=caption)
@contract(name='str', value='array', filter='str', caption='None|str')
def array_as_image(self, name, value,
filter='posneg', # @ReservedAssignment # XXX: config
filter_params={},
caption=None): # @ReservedAssignment
# try image XXX check uint8
# If this is RGB
if len(value.shape) == 3 and value.shape[2] == 3:
# zoom images smaller than 50
# if value.shape[0] < 50:
# value = zoom(value, 10)
self.fig().data_rgb(name, value, caption=caption)
else:
node = self.r.data(name, value, mime=MIME_PYTHON, caption=caption)
m = node.display(filter, **filter_params)
if caption is None:
caption = name
self.fig().sub(m, caption=caption)
@contract(name='str', value='str')
def text(self, name, value):
self.r.text(name, value)
@contextmanager
@contract(name='str', caption='None|str')
def plot(self, name, caption=None, **args):
f = self.fig()
# TODO: make a child of myself
with f.plot(name, caption=caption, **args) as pylab:
yield pylab
def section(self, section_name, cols=default_max_cols, caption=None):
child = self.r.node(section_name, caption=caption)
return ReprepPublisher(report=child, cols=cols)
示例6: create_report_delayed
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def create_report_delayed(exp_id, delayed, description):
delays = numpy.array(sorted(delayed.keys()))
r = Report(exp_id)
r.text("description", description)
f = r.figure(cols=3)
# max and sum of correlation for each delay
# corr_max = []
corr_mean = []
for delay in delays:
data = delayed[delay]
a = data["action_image_correlation"]
id = "delay%d" % delay
# rr = r.node('delay%d' % delay)
r.data(id, a).data_rgb("retina", add_reflines(posneg(values2retina(a))))
corr_mean.append(numpy.abs(a).mean())
caption = "delay: %d (max: %.3f, sum: %f)" % (delay, numpy.abs(a).max(), numpy.abs(a).sum())
f.sub(id, caption=caption)
timestamp2ms = lambda x: x * (1.0 / 60) * 1000
peak = numpy.argmax(corr_mean)
peak_ms = timestamp2ms(delays[peak])
with r.data_pylab("mean") as pylab:
T = timestamp2ms(delays)
pylab.plot(T, corr_mean, "o-")
pylab.ylabel("mean correlation field")
pylab.xlabel("delay (ms) ")
a = pylab.axis()
pylab.plot([0, 0], [a[2], a[3]], "k-")
y = a[2] + (a[3] - a[2]) * 0.1
pylab.text(+5, y, "causal", horizontalalignment="left")
pylab.text(-5, y, "non causal", horizontalalignment="right")
pylab.plot([peak_ms, peak_ms], [a[2], max(corr_mean)], "b--")
y = a[2] + (a[3] - a[2]) * 0.2
pylab.text(peak_ms + 10, y, "%d ms" % peak_ms, horizontalalignment="left")
f = r.figure("stats")
f.sub("mean")
a = delayed[int(delays[peak])]["action_image_correlation"]
r.data_rgb("best_delay", add_reflines(posneg(values2retina(a))))
return r
示例7: report_predstats
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def report_predstats(id_discdds, id_subset, id_distances, records):
r = Report('predistats-%s-%s' % (id_discdds, id_subset))
print records.dtype
r.data('records', records)
f = r.figure()
colors = list(islice(cycle(['r', 'g', 'b', 'k', 'y', 'm']), 50))
delta = records['delta']
W = 0.2
# pdb.set_trace()
# Save the raw values
for i, id_d in enumerate(id_distances):
r.data(id_d, records[id_d])
with f.plot('values_order', **dp_predstats_fig) as pylab:
ax = pylab.subplot(111)
for i, id_d in enumerate(id_distances):
distance = records[id_d]
distance_order = scale_score(distance) / (float(distance.size) - 1)
step = float(i) / max(len(id_distances) - 1, 1)
xstep = W * 2 * (step - 0.5)
fancy_error_display(ax, delta + xstep, distance_order,
colors[i], perc=10, label=id_d)
ieee_spines(pylab)
ticks = sorted(list(set(list(delta))))
pylab.xlabel('interval length')
pylab.ylabel('normalized distance')
pylab.xticks(ticks, ticks)
pylab.yticks((0, 1), (0, 1))
pylab.axis((0.5, 0.5 + np.max(delta), -0.024, 1.2))
legend_put_below(ax)
with f.plot('values', **dp_predstats_fig) as pylab:
ax = pylab.subplot(111)
for i, id_d in enumerate(id_distances):
distance = records[id_d]
step = float(i) / max(len(id_distances) - 1, 1)
xstep = W * 2 * (step - 0.5)
fancy_error_display(ax, delta + xstep, distance,
colors[i], perc=10, label=id_d)
ieee_spines(pylab)
ticks = sorted(list(set(list(delta))))
pylab.xlabel('interval length')
pylab.ylabel('distance')
pylab.xticks(ticks, ticks)
# pylab.yticks((0, 1), (0, 1))
a = pylab.axis()
pylab.axis((0.5, 0.5 + np.max(delta), -0.024, a[3]))
legend_put_below(ax)
return r
示例8: aer_simple_stats_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def aer_simple_stats_report(stats):
r = Report("simplestatsreport")
f = r.figure()
for n in ["h_all", "h_plus", "h_minus"]:
h = stats[n]
cap = "%d events" % (h.sum())
r.data(n, h).display("scale").add_to(f, caption=cap)
return r
示例9: basic_plots
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def basic_plots(d):
G = d.G
#G = skim_top_and_bottom(G, 1)
#max_value = numpy.abs(G).max()
r = Report('plots')
f = r.figure('The learned G', cols=2)
cmd = {0: 'vx', 1: 'vy', 2: 'omega'}
grad = {0: 'hor', 1: 'vert'}
for (k, j) in itertools.product([0, 1, 2], [0, 1]):
x = G[k, j, :, :].squeeze()
#max_value = numpy.abs(G[k, ...]).max()
n = r.data('G%d%d' % (k, j), x).display('posneg')
f.sub(n, 'G %s %s' % (cmd[k], grad[j]))
P = d.P
f = r.figure('The covariance of gradient', cols=2)
for (i, j) in itertools.product([0, 1], [0, 1]):
x = P[i, j, :, :].squeeze()
if i == j: x = scale_score(x)
display = "scale" if i == j else "posneg"
n = r.data('cov%d%d' % (i, j), x).display(display)
f.sub(n, 'cov %s %s' % (grad[i], grad[j]))
f = r.figure('The inverse of the covariance', cols=2)
P_inv = d.P_inv
#P_inv = skim_top_and_bottom(P_inv, 5)
for (i, j) in itertools.product([0, 1], [0, 1]):
x = P_inv[i, j, :, :].squeeze()
if i == j: x = scale_score(x)
display = "scale" if i == j else "posneg"
n = r.data('P_inv%d%d' % (i, j), x).display(display)
f.sub(n, 'P_inv %s %s' % (grad[i], grad[j]))
Gn = d.Gn
f = r.figure('Normalized G', cols=2)
for (k, j) in itertools.product([0, 1, 2], [0, 1]):
x = Gn[k, j, :, :].squeeze()
n = r.data('Gn%d%d' % (k, j), x).display('posneg')
f.sub(n, 'Gn %s %s' % (cmd[k], grad[j]))
Gnn = d.Gnn
#max_value = numpy.abs(Gnn).max()
f = r.figure('Normalized G (also inputs)', cols=2)
for (k, j) in itertools.product([0, 1, 2], [0, 1]):
x = Gnn[k, j, :, :].squeeze()
max_value = numpy.abs(Gnn[k, ...]).max()
#max_value = numpy.abs(x).max()
n = r.data('Gnn%d%d' % (k, j), x).display('posneg', max_value=max_value)
f.sub(n, 'Gnn %s %s' % (cmd[k], grad[j]))
plot_hist_for_4d_tensor(r, G, 'G', 'Histograms for G')
plot_hist_for_4d_tensor(r, P, 'P', 'Histograms for P (covariance)')
return r
示例10: ground_truth_plots
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def ground_truth_plots(d):
r = Report()
f = r.figure(cols=3)
n = r.data('cosine', d.C).display('posneg')
f.sub(n, 'Cosine matrix')
n = r.data('dist', d.D).display('scale')
f.sub(n, 'Distance matrix')
return r
示例11: show_some_correlations
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def show_some_correlations(d, num=30, cols=6):
r = Report('sensels correlations')
f = r.figure('Correlations of some sensels.', cols=cols)
s = d.R.sum(axis=0)
r.data('sum', d.toimg(s)).display('posneg')
f.sub('sum', caption="Sum of correlations")
for i in range(num):
id = 'sensel%d' % i
Ri = d.toimg(d.R[i, :])
r.data(id, Ri).display('posneg')
f.sub(id)
return r
示例12: estimation
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def estimation(fid, f): # @UnusedVariable
shape = [50, 50]
diffeo = diffeomorphism_from_function(shape, f)
K = 50
epsilon = 1
de = DiffeomorphismEstimator([0.2, 0.2], MATCH_CONTINUOUS)
for y0, y1 in generate_input(shape, K, diffeo, epsilon=epsilon):
de.update(y0, y1)
diff2d = de.summarize()
diffeo_learned = diff2d.d
from reprep import Report
name = f.__name__
r = Report(name)
fig = r.figure(cols=4)
diffeo_learned_rgb = diffeomorphism_to_rgb_cont(diffeo_learned)
diffeo_rgb = diffeomorphism_to_rgb_cont(diffeo)
r.data_rgb('diffeo_rgb', diffeo_rgb).add_to(fig)
r.data_rgb('diffeo_learned_rgb', diffeo_learned_rgb).add_to(fig)
L = r.data('diffeo_learned_uncertainty', diff2d.variance)
L.display('scale').add_to(fig, caption='uncertainty')
r.data('last_y0', y0).display('scale').add_to(fig, caption='last y0')
r.data('last_y1', y1).display('scale').add_to(fig, caption='last y1')
cs = [(0, 25), (10, 25), (25, 25), (25, 5)]
for c in cs:
M25 = de.get_similarity(c)
r.data('cell-%s-%s' % c, M25).display('scale').add_to(fig,
caption='Example similarity field')
filename = 'out/diffeo_estimation_suite/%s.html' % name
print('Writing to %r.' % filename)
r.to_html(filename)
示例13: report_uncert_stats
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def report_uncert_stats(records, id_ddss):
# records = stats['records']
r = Report('uncert-statsall')
r.data('records', records)
f = r.figure()
id_distances = ['L2', 'L2w']
colors = list(islice(cycle(['r', 'g', 'b', 'k', 'y', 'm']), 50))
perc = 10
W = 0.2
with f.plot('distance', **dp_predstats_fig) as pylab:
ax = pylab.subplot(111)
for i, id_dds in enumerate(id_ddss):
which = records['id_discdds'] == id_dds
delta = records[which]['delta']
distance = records[which]['L2w']
if i == 0:
distance0 = records[which]['L2']
step = float(0) / max(len(id_distances) - 1, 1)
xstep = W * 2 * (step - 0.5)
fancy_error_display(ax, delta + xstep, distance0,
colors[0], perc=perc,
label='L2')
step = float(i + 1) / max(len(id_distances) - 1, 1)
xstep = W * 2 * (step - 0.5)
fancy_error_display(ax, delta + xstep, distance,
colors[i + 1], perc=perc, label='L2w' + id_dds)
legend_put_below(ax)
return r
示例14: correlation_embedding_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def correlation_embedding_report(R, num_eig=6):
imshape = (100, 100)
toimg = lambda x : x.reshape(imshape)
U, S, V = numpy.linalg.svd(R, full_matrices=0) #@UnusedVariable
r = Report('correlation_embedding')
fv = r.figure('V', caption='Coordinates of the embedding')
for k in range(num_eig):
v = V[k, :] * numpy.sqrt(S[k])
print v.size
id = 'eig_v_%d' % k
n = r.data(id, toimg(v)).display('posneg')
fv.sub(n, caption='Eigenvector #%d' % k)
return r
示例15: old_analysis
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data [as 别名]
def old_analysis(data):
R = data['correlation']
variance = data['variance']
num_sensels = max(R.shape)
# XXX
imshape = (100, 100)
num_coords_keep = 10
num_sensels_display = 100
r = Report('calibrator_plots')
f0 = r.figure(cols=5, caption='Main quantities')
f1 = r.figure(cols=6)
f2 = r.figure(cols=6)
f3 = r.figure(cols=6, caption='distances in sensing space')
f4 = r.figure(cols=6, caption='dependency between eigenvectors')
f0.sub(r.data('variance', variance.reshape(imshape)).display('scale', min_value=0),
caption='Variance (darker=stronger)')
with r.data_pylab('variance_scalar') as pylab:
pylab.hist(variance)
f0.sub('variance_scalar')
for i in range(num_sensels_display):
id = 'sensel%d' % i
Ri = R[i, :].reshape(imshape)
r.data(id, Ri)
f1.sub(id, display='posneg')
U, S, V = numpy.linalg.svd(R, full_matrices=0) #@UnusedVariable
coords = numpy.zeros(shape=(num_sensels, num_coords_keep))
# set coordinates
for k in range(num_coords_keep):
v = V[k, :] * numpy.sqrt(S[k])
coords[:, k] = v
# normalize coords
if False:
for i in range(num_sensels):
coords[i, :] = coords[i, :] / numpy.linalg.norm(coords)
for k in range(num_coords_keep):
id = 'coord%d' % k
M = coords[:, k].reshape(imshape)
r.data(id, M)
f2.sub(id, display='posneg')
# compute the distance on the sphere for some sensel
for w in RandomExtract.choose_selection(30, num_sensels):
D = numpy.zeros(num_sensels)
s = 14 # number of coordinates
p1 = coords[w, 0:s] / numpy.linalg.norm(coords[w, 0:s])
for i in range(num_sensels):
p2 = coords[i, 0:s] / numpy.linalg.norm(coords[i, 0:s])
D[i] = numpy.linalg.norm(p1 - p2)
D_sorted = numpy.argsort(D)
neighbors = 50
D[D_sorted[:neighbors]] = 0
D[D_sorted[neighbors:]] = 1
# D= D_sorted
id = 'dist%s' % w
r.data(id, D.reshape(imshape))
f3.sub(id, display='scale')
# Divide the sensels in classes
if False:
ncoords_classes = 5
classes = numpy.zeros((num_sensels))
for k in range(ncoords_classes):
c = coords[:, k]
cs = divide_in_classes(c, 3)
classes += cs * (3 ** k)
f0.sub(r.data('classes', classes.reshape(imshape)).display('posneg'))
if True:
nclasses = 20
classes = group_by_correlation(R[:nclasses, :])
f0.sub(r.data('classes_by_R', classes.reshape(imshape)).display('scale'))
if False:
ncoords = 10
print("computing similarity matrix")
coord_similarity = numpy.zeros((ncoords, ncoords))
for k1, k2 in itertools.product(range(ncoords), range(ncoords)):
if k1 == k2:
coord_similarity[k1, k2] = 0 # numpy.nan
continue
if k1 < k2:
continue
c1 = coords[:, k1]
c2 = coords[:, k2]
step = 4
#.........这里部分代码省略.........