# HG changeset patch # User Henry S. Thompson # Date 1701123293 0 # Node ID 45120df952be7f8183f963889c866b7629432e30 # Parent 0058e523f6497845396cf1f374982c4f49ae3532 add head_map fn diff -r 0058e523f649 -r 45120df952be lib/python/cc/ccstats.py --- a/lib/python/cc/ccstats.py Mon Nov 27 18:25:39 2023 +0000 +++ b/lib/python/cc/ccstats.py Mon Nov 27 22:14:53 2023 +0000 @@ -210,6 +210,21 @@ ds2 = delta2 / stdev print(n,p,q,'%6.4g'%delta1,'%4.2g'%ds1,'%6.4g'%delta2,'%4.2g'%ds2) +def heat_map(basis_ym, basis_names, target_ym, target_names, nn, outf = sys.stdout): + nn=nn if isinstance(nn,list) else list(nn) + with (outf if outf is sys.stdout else open(outf,'w')) as outfile: + print("\tN",file=outfile) + print("Predict","\t".join(["{:d}"]*len(nn)).format(*nn),sep="\t",file=outfile) + for p in basis_names: + for q in target_names: + basis=SS[f'{basis_ym} {p}'] + target=SS[f'{target_ym} {q}'] + best = (stats.describe(target.all[np.array(basis.iranks_by_all[:n])]).mean + for n in nn) + print(f"{q} by {p}", + "\t".join(['{:6.4g}']*len(nn)).format(*best), + sep="\t",file=outfile) + def predict(basis_ym, basis_name, target_ym, target_name, n): basis = SS['%s %s'%(basis_ym, basis_name)] target = SS['%s %s'%(target_ym, target_name)]