Use as_frame=False when calling fetch_openml()

This commit is contained in:
Aurélien Geron
2021-03-02 09:29:06 +13:00
parent 5663779ae8
commit 346dfe6d1e
4 changed files with 35 additions and 7 deletions

View File

@@ -1381,6 +1381,13 @@
"First, let's load the dataset and split it into a training set and a test set. We could use `train_test_split()` but people usually just take the first 60,000 instances for the training set, and the last 10,000 instances for the test set (this makes it possible to compare your model's performance with others): "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Warning:** since Scikit-Learn 0.24, `fetch_openml()` returns a Pandas `DataFrame` by default. To avoid this, we use `as_frame=False`."
]
},
{
"cell_type": "code",
"execution_count": 47,
@@ -1388,7 +1395,7 @@
"outputs": [],
"source": [
"from sklearn.datasets import fetch_openml\n",
"mnist = fetch_openml('mnist_784', version=1, cache=True)\n",
"mnist = fetch_openml('mnist_784', version=1, cache=True, as_frame=False)\n",
"\n",
"X = mnist[\"data\"]\n",
"y = mnist[\"target\"].astype(np.uint8)\n",
@@ -1837,7 +1844,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.8"
"version": "3.7.9"
},
"nav_menu": {},
"toc": {