|
137 | 137 | "import os\n",
|
138 | 138 | "# The file has no headers naming the columns, so we pass header=None\n",
|
139 | 139 | "# and provide the column names explicitly in \"names\"\n",
|
| 140 | + "adult_path = os.path.join(mglearn.datasets.DATA_PATH, \"adult.data\")\n", |
140 | 141 | "data = pd.read_csv(\n",
|
141 |
| - " os.path.join(mglearn.datasets.DATA_PATH, \"adult.data\"), header=None, index_col=False,\n", |
| 142 | + " adult_path, header=None, index_col=False,\n", |
142 | 143 | " names=['age', 'workclass', 'fnlwgt', 'education', 'education-num',\n",
|
143 | 144 | " 'marital-status', 'occupation', 'relationship', 'race', 'gender',\n",
|
144 | 145 | " 'capital-gain', 'capital-loss', 'hours-per-week', 'native-country',\n",
|
|
1347 | 1348 | }
|
1348 | 1349 | ],
|
1349 | 1350 | "source": [
|
1350 |
| - "plt.hist(np.log(X_train_log[:, 0] + 1), bins=25, color='gray')\n", |
| 1351 | + "plt.hist(X_train_log[:, 0], bins=25, color='gray')\n", |
1351 | 1352 | "plt.ylabel(\"Number of appearances\")\n",
|
1352 | 1353 | "plt.xlabel(\"Value\")"
|
1353 | 1354 | ]
|
|
1787 | 1788 | "source": [
|
1788 | 1789 | "# extract the target values (number of rentals)\n",
|
1789 | 1790 | "y = citibike.values\n",
|
1790 |
| - "# convert the time to posixtime using \"%s\"\n", |
1791 |
| - "X = citibike.index.strftime(\"%s\").astype(\"int\").reshape(-1, 1)" |
| 1791 | + "# convert to POSIX time by dividing by 10**9\n", |
| 1792 | + "X = citibike.index.astype(\"int64\").values.reshape(-1, 1) // 10**9" |
1792 | 1793 | ]
|
1793 | 1794 | },
|
1794 | 1795 | {
|
|
0 commit comments