Chapter 2: "Setup" & "Get the data" code improvement
parent
80e59e1dd1
commit
7e4f99085f
|
@ -61,13 +61,15 @@
|
|||
"# Where to save the figures\n",
|
||||
"PROJECT_ROOT_DIR = \".\"\n",
|
||||
"CHAPTER_ID = \"end_to_end_project\"\n",
|
||||
"IMAGES_PATH = os.path.join(PROJECT_ROOT_DIR, \"images\", CHAPTER_ID)\n",
|
||||
"FIG_EXTENSION = \"png\"\n",
|
||||
"\n",
|
||||
"def save_fig(fig_id, tight_layout=True):\n",
|
||||
" path = os.path.join(PROJECT_ROOT_DIR, \"images\", CHAPTER_ID, fig_id + \".png\")\n",
|
||||
" path = os.path.join(IMAGES_PATH, fig_id + \".\" + FIG_EXTENSION)\n",
|
||||
" print(\"Saving figure\", fig_id)\n",
|
||||
" if tight_layout:\n",
|
||||
" plt.tight_layout()\n",
|
||||
" plt.savefig(path, format='png', dpi=300)"
|
||||
" plt.savefig(path, format=FIG_EXTENSION, dpi=300)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -91,7 +93,7 @@
|
|||
"\n",
|
||||
"DOWNLOAD_ROOT = \"https://raw.githubusercontent.com/ageron/handson-ml/master/\"\n",
|
||||
"HOUSING_PATH = os.path.join(\"datasets\", \"housing\")\n",
|
||||
"HOUSING_URL = DOWNLOAD_ROOT + \"datasets/housing/housing.tgz\"\n",
|
||||
"HOUSING_URL = DOWNLOAD_ROOT + HOUSING_PATH + \"/housing.tgz\"\n",
|
||||
"\n",
|
||||
"def fetch_housing_data(housing_url=HOUSING_URL, housing_path=HOUSING_PATH):\n",
|
||||
" if not os.path.isdir(housing_path):\n",
|
||||
|
@ -2313,7 +2315,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.2"
|
||||
"version": "3.5.4"
|
||||
},
|
||||
"nav_menu": {
|
||||
"height": "279px",
|
||||
|
|
Loading…
Reference in New Issue