-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from deepskies/issue/jupyter_install
Issue/jupyter install
- Loading branch information
Showing
4 changed files
with
4,413 additions
and
906 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "09fcc173-1f36-4f32-8b22-d3f4c4307fc7", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"import pandas as pd\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"from data.data import MyDataLoader, DataPreparation" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ab352b73-3515-42b7-9d92-f49a5e8485c8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# lookup dict\n", | ||
"noise_to_sigma = {\n", | ||
" 'low': 0.01,\n", | ||
" 'medium': 0.05,\n", | ||
" 'high': 0.10,\n", | ||
" 'vhigh': 1.00\n", | ||
"}\n", | ||
"inject_x_image = {'low': 0.01/32, 'medium': 0.05/32, 'high': 0.10/32}\n", | ||
"noise = 'high'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "4760fcec-b43c-477d-abaf-b8407ba257b4", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data = DataPreparation()\n", | ||
"size_df = 1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "76baf2a1-fb9c-43be-8deb-51e5e71d48ac", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fig = plt.figure(figsize=(10,4))\n", | ||
"\n", | ||
"data.params = np.array([[ 0.2, 0]])\n", | ||
"\n", | ||
"\n", | ||
"ax1 = fig.add_subplot(141)\n", | ||
"data.simulate_data(data.params,\n", | ||
" noise_to_sigma[noise], \n", | ||
" simulation_name = 'linear_homoskedastic',\n", | ||
" x=np.linspace(0, 10, 100),\n", | ||
" inject_type = 'predictive'\n", | ||
" )\n", | ||
"ax1.plot(np.array(data.input), np.array(data.output).flatten(), color = 'black')\n", | ||
"ax1.scatter(np.array(data.input), np.array(data.output), color = 'black', s=0.25, zorder=-100)\n", | ||
"ax1.set_title(r'$\\sigma_y = $'+str(noise_to_sigma[noise]))\n", | ||
"ax1.set_xlabel(r'$x$', size=15)\n", | ||
"ax1.set_ylabel(r'$y$', size=15, rotation=90)\n", | ||
"ax1.set_aspect(5, adjustable='box')\n", | ||
"\n", | ||
"\n", | ||
"ax0 = fig.add_subplot(142)\n", | ||
"data.simulate_data(data.params,\n", | ||
" noise, \n", | ||
" simulation_name = 'linear_homoskedastic',\n", | ||
" x=np.linspace(0, 10, 100),\n", | ||
" inject_type = 'feature',\n", | ||
" vary_sigma = True\n", | ||
" )\n", | ||
"ax0.plot(np.array(data.input).flatten(), np.array(data.output).flatten(), color = 'black')\n", | ||
"ax0.scatter(np.array(data.input), np.array(data.output), color = 'black', s=0.25, zorder=-100)\n", | ||
"#ax0.set_title('Input injection', size=15)\n", | ||
"ax0.set_title(r'$\\sigma_x = $'+str(round(noise_to_sigma[noise] / data.params[0][0],3))+\n", | ||
" r'$\\rightarrow \\sigma_y = $'+str(round(noise_to_sigma[noise],3)))\n", | ||
"ax0.set_xlabel(r'$x$', size=15)\n", | ||
"\n", | ||
"ax0.set_aspect(5, adjustable='box')\n", | ||
"#ax.set_aspect('equal', adjustable='box')\n", | ||
"\n", | ||
"# now doing 2D\n", | ||
"data.params = np.array([[ 0.005, 5, 0.69598183]])\n", | ||
"image_size = 32\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"ax3 = fig.add_subplot(143)\n", | ||
"\n", | ||
"image_p, y_p = data.simulate_data_2d(\n", | ||
" size_df,\n", | ||
" data.params,\n", | ||
" inject_type=\"predictive\",\n", | ||
" sigma=noise_to_sigma[noise]\n", | ||
" )\n", | ||
"ax3.imshow(image_p[0])\n", | ||
"ax3.annotate('y = ' + str(round(y_p[0], 2)),\n", | ||
" xy=(0.2, 0.05),\n", | ||
" xycoords='axes fraction',\n", | ||
" color='white',\n", | ||
" size=15)\n", | ||
"ax3.set_title(r'$\\sigma_y = $' + str(noise_to_sigma[noise]))\n", | ||
"\n", | ||
"#ax3.set_title('Output injection', size=15)\n", | ||
"\n", | ||
"\n", | ||
"ax2 = fig.add_subplot(144)\n", | ||
"\n", | ||
"image_f, y_f = data.simulate_data_2d(\n", | ||
" size_df,\n", | ||
" data.params,\n", | ||
" inject_type=\"feature\",\n", | ||
" sigma=inject_x_image[noise]\n", | ||
" )\n", | ||
"ax2.imshow(image_f[0])\n", | ||
"ax2.annotate('y = ' + str(round(y_f[0], 2)),\n", | ||
" xy=(0.2, 0.05),\n", | ||
" xycoords='axes fraction',\n", | ||
" color='white',\n", | ||
" size=15)\n", | ||
"ax2.set_title(r'$\\sigma_x = $' + str(round(noise_to_sigma[noise]/32, 3)) \n", | ||
" + r'$\\rightarrow \\sigma_y = $' + str(noise_to_sigma[noise]))\n", | ||
"ax1.annotate('(a)', xy=(0.02, 0.88), xycoords='axes fraction', size=15, color='black')\n", | ||
"ax0.annotate('(b)', xy=(0.02, 0.88), xycoords='axes fraction', size=15, color='black')\n", | ||
"ax2.annotate('(d)', xy=(0.02, 0.88), xycoords='axes fraction', size=15, color='white')\n", | ||
"ax3.annotate('(c)', xy=(0.02, 0.88), xycoords='axes fraction', size=15, color='white')\n", | ||
"\n", | ||
"\n", | ||
"# Add a shared title for the first two subplots\n", | ||
"fig.text(0.31, 0.83, '0D Data', ha='center', fontsize=15)\n", | ||
"\n", | ||
"# Draw a bracket pointing to the first two subplots\n", | ||
"x_bracket = [0.15, 0.15, 0.45, 0.45] # x-coordinates of the bracket\n", | ||
"y_bracket = [0.77, 0.81, 0.81, 0.77] # y-coordinates of the bracket\n", | ||
"plt.plot(x_bracket, y_bracket, color='black', lw=1.5, transform=fig.transFigure, clip_on=False)\n", | ||
"\n", | ||
"# Add a shared title for the first two subplots\n", | ||
"fig.text(0.71, 0.83, '2D Data', ha='center', fontsize=15)\n", | ||
"\n", | ||
"# Draw a bracket pointing to the first two subplots\n", | ||
"x_bracket = [0.56, 0.56, 0.86, 0.86] # x-coordinates of the bracket\n", | ||
"y_bracket = [0.77, 0.81, 0.81, 0.77] # y-coordinates of the bracket\n", | ||
"plt.plot(x_bracket, y_bracket, color='black', lw=1.5, transform=fig.transFigure, clip_on=False)\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"#plt.tight_layout()\n", | ||
"plt.savefig('../../../Desktop/design_'+str(noise)+'.png', dpi=1000)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8df66b56-e524-405a-a7bd-c81c4a391594", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.