ageron / ageron/handson-ml2

Chapter 9 notebook minor issues

Aperta
#312 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Jupyter Notebook
Stelle
30k
Fork
13.1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hi,

It seems that there are somes issues or differences with my execution of the chapter 9 handbook.

My configuration :
```
print(sys.version_info)
print(sklearn.__version__)
print(np.__version__)
print(mpl.__version__)
```
> sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0)
> 0.23.2
> 1.19.2
> 3.3.2
>

**9.1 : Iris classification and GaussianMixture**

It seems that the mapping of the prediction has changed in the GaussianMixture class in the sklearn version I use. Here is the code that works in my case :
```
y_pred = GaussianMixture(n_components=3, random_state=42).fit(X).predict(X)
mapping = np.array([1, 2, 0])
y_pred = np.array([mapping[cluster_id] for cluster_id in y_pred])
```

**9.1.1 : plot_centroid function**

The size of the cross is not correct in the handbook : it creates this (i used a different random_state for input data) :
![image](https://user-images.githubusercontent.com/73541689/98441387-351ff180-20fe-11eb-8e55-4c2f0a433b11.png)
instead of this :
![image](https://user-images.githubusercontent.com/73541689/98441423-70babb80-20fe-11eb-8951-6cd911903942.png)
This image was generated with the following code :
```
def plot_centroids(centroids, weights=None, circle_color='w', cross_color='k'):
if weights is not None:
centroids = centroids[weights > weights.max() / 10]
plt.scatter(centroids[:, 0], centroids[:, 1],
marker='o', s=50, linewidths=8,
color=circle_color, zorder=10, alpha=0.9)
plt.scatter(centroids[:, 0], centroids[:, 1],
marker='x', s=50, linewidths=2,
color=cross_color, zorder=11, alpha=1)
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.