Datasets:
Formats:
csv
Languages:
English
Size:
< 1K
Tags:
mathematics
linear-algebra
convex-optimization
optimal-recovery
neural-representations
robustness
Download research/experiments/create_figures.py from PureOne/luminous-hypercontinuum-foundation-v3: direct link, hf CLI and curl.
- Browser
- Download file 3.23 kB
-
https://huggingface.co/datasets/PureOne/luminous-hypercontinuum-foundation-v3/resolve/main/research/experiments/create_figures.py
- Command line
-
hf download hf://datasets/PureOne/luminous-hypercontinuum-foundation-v3/research/experiments/create_figures.py
-
curl -L -o create_figures.py https://huggingface.co/datasets/PureOne/luminous-hypercontinuum-foundation-v3/resolve/main/research/experiments/create_figures.py
3.23 kB
| """Recreate the seven publication figures from recorded results. | |
| No selected plot colors or style package; Matplotlib's default cycle is used. | |
| """ | |
| from pathlib import Path | |
| import json | |
| import numpy as np | |
| import matplotlib | |
| matplotlib.use('Agg') | |
| import matplotlib.pyplot as plt | |
| ROOT = Path(__file__).resolve().parents[1] | |
| OUT = ROOT / 'figures' | |
| OUT.mkdir(exist_ok=True) | |
| v = json.loads((ROOT/'data/mathematical_verification.json').read_text()) | |
| b = json.loads((ROOT/'data/neural_digits_results.json').read_text()) | |
| def save(fig, name): | |
| fig.tight_layout() | |
| fig.savefig(OUT/f'{name}.pdf', bbox_inches='tight') | |
| fig.savefig(OUT/f'{name}.png', dpi=180, bbox_inches='tight') | |
| plt.close(fig) | |
| curve = v['frontier_curve'] | |
| fig, ax = plt.subplots(figsize=(7.2,4.5)) | |
| ax.plot([r['B'] for r in curve],[r['exact'] for r in curve],label='Exact optimal frontier') | |
| ax.plot([r['B'] for r in curve],[r['uniform'] for r in curve],'--',label='Uniform contraction') | |
| ax.axvline(np.log(2),linestyle=':',label='Regime boundary: B = log 2') | |
| ax.set(xlabel='Total log-contraction budget B',ylabel='Worst-scenario information floor') | |
| ax.legend(); ax.grid(alpha=.2); save(fig,'noncommuting_frontier') | |
| fig,ax=plt.subplots(figsize=(7.2,4.5)); n=np.arange(1,21) | |
| ax.plot(n,(7/5)**(n/2),marker='o') | |
| ax.set(xlabel='Number of tensor factors',ylabel='Full-memory / compressed-memory information floor') | |
| ax.set_xticks([1,5,10,15,20]);ax.grid(alpha=.2);save(fig,'memory_amplification') | |
| for metric,ylabel,name in [ | |
| ('mean_accuracy','Mean held-out accuracy','neural_accuracy'), | |
| ('mean_reconstruction_RMSE','Mean latent-state reconstruction RMSE','neural_reconstruction'), | |
| ('mean_certified_stability','Certified prediction-stability fraction','neural_certificates')]: | |
| fig,ax=plt.subplots(figsize=(7.2,4.5)) | |
| for method in ['uniform','optimized']: | |
| rows=[r for r in b['aggregates'] if r['method']==method] | |
| ax.plot([r['noise_norm'] for r in rows],[r[metric] for r in rows],marker='o',label=method.capitalize()) | |
| ax.set(xlabel='Aggregate observation-noise norm',ylabel=ylabel) | |
| ax.legend();ax.grid(alpha=.2);save(fig,name) | |
| fig,ax=plt.subplots(figsize=(7.2,4.5)); h=np.linspace(0,1.2,301) | |
| d,s,R=4,.6,1.;tail=(d+1)**(-2*s) | |
| exact=np.where(h<R,np.sqrt(h*h+(R*R-h*h)*tail),R) | |
| ax.plot(h,exact,label='New release: exact minimax radius') | |
| ax.plot(h,np.sqrt(h*h+R*R*tail),'--',label='Inherited v2 upper bound') | |
| ax.plot(h,np.maximum(np.minimum(R,h),R*np.sqrt(tail)),':',label='Inherited v2 lower bound') | |
| ax.set(xlabel='Effective noise h = ε/q',ylabel='Worst-case recovery radius') | |
| ax.legend();ax.grid(alpha=.2);save(fig,'exact_ellipsoid_recovery') | |
| fig,ax=plt.subplots(figsize=(6.2,5.2)); a=np.linspace(0,2*np.pi,401) | |
| circle=np.vstack([np.cos(a),np.sin(a)]) | |
| for matrix,label in [(np.array([[2.,2.],[2.,8.]]),'Scenario +'), | |
| (np.array([[2.,-2.],[-2.,8.]]),'Scenario −'), | |
| (np.diag([1.,4.]),'Common maximum-volume ellipse')]: | |
| ev,u=np.linalg.eigh(matrix);ellipse=((u*np.sqrt(ev))@u.T)@circle | |
| ax.plot(ellipse[0],ellipse[1],label=label) | |
| ax.set(xlabel='First coordinate',ylabel='Second coordinate',aspect='equal') | |
| ax.legend(fontsize=8);ax.grid(alpha=.2);save(fig,'common_ellipse') | |
| print('Seven figures regenerated in PDF and PNG formats.') | |