ageron / ageron/handson-ml2

[BUG] 03_classification.ipynb - Assignment issue between DataFrame to Array

Open
#452 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

I am not a python expert but I realized there is probably a compatibility issue with following code:

```python
%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt

some_digit = X[0]
some_digit_image = some_digit.reshape(28, 28)
plt.imshow(some_digit_image, cmap=mpl.cm.binary)
plt.axis("off")

save_fig("some_digit_plot")
plt.show()
```

The assignment `some_digit = X[0]` throws an error.

I managed to fix this like this:

```python
%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt

some_digit = X[0:1]
some_digit_arr = np.asarray(some_digit)
some_digit_image = some_digit_arr.reshape(28, 28)

plt.imshow(some_digit_image, cmap="binary")
plt.axis("off")

save_fig("some_digit_plot")
plt.show()
```

Thank you.

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.