ageron / ageron/handson-ml2

[QUESTION]-Chap3 Classification

Open
#536 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
30k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

**KeyError: 0** is thrown as an error while the below set of code is executed.

```
import matplotlib as mpl
import matplotlib.pyplot as plt
digit = x[0]

digit = digit.reshape(28, 28)

plt.imshow(digit, cmap="binary")
plt.axis("off")
plt.show()
```

Full stacktrace here:

```
KeyError Traceback (most recent call last)
[/usr/local/lib/python3.7/dist-packages/pandas/core/indexes/base.py](https://localhost:8080/#) in get_loc(self, key, method, tolerance)
3360 try:
-> 3361 return self._engine.get_loc(casted_key)
3362 except KeyError as err:

4 frames
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 0

The above exception was the direct cause of the following exception:

KeyError Traceback (most recent call last)
[/usr/local/lib/python3.7/dist-packages/pandas/core/indexes/base.py](https://localhost:8080/#) in get_loc(self, key, method, tolerance)
3361 return self._engine.get_loc(casted_key)
3362 except KeyError as err:
-> 3363 raise KeyError(key) from err
3364
3365 if is_scalar(key) and isna(key) and not self.hasnans:

KeyError: 0

```

**Expected behavior**

Should print a image as below
Screenshot 2022-02-03 at 10 56 22 AM

**Screenshot**
Screenshot 2022-02-03 at 10 54 52 AM

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.