I read the book "Introduction to machine learning." There is such an example in python :

 import numpy as np import matplotlib.pyplot as plt import pandas as pd import mglearn from sklearn.datasets import load_iris iris_dataset = load_iris() from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(iris_dataset['data'], iris_dataset['target'], random_state=0) iris_dataframe = pd.DataFrame(X_train, columns=iris_dataset.feature_names) pd.plotting.scatter_matrix( iris_dataframe, c=y_train, figsize=(15, 15), marker='o', hist_kwds={'bins': 20}, s=60, alpha=.8, cmap=mglearn.cm3 ) 

In the end, the graphy should be rendered, but nothing happens. According to the documentation, I’m doing everything right. What could be the problem?

  • 2
    Add at the beginning:% matplotlib inline - MaxU

1 answer 1

Where have you forgotten about plt

 plt(pd.plotting.scatter_matrix( iris_dataframe, c=y_train, figsize=(15, 15), marker='o', hist_kwds={'bins': 20}, s=60, alpha=.8, cmap=mglearn.cm3 )) 

And yes, the case says MaxU
"Add at the beginning:
% matplotlib inline
"

  • Pandas (alias pd ) does a great job with drawing graphs, so plt() wrapping is superfluous ... - MaxU