0

There is my code (example code from book about machine learning), but it doesn't appear pd.plotting.scatter_matrix in the end.

import sys
import mglearn as mglearn
import pandas as pd
from pandas.plotting import scatter_matrix
import tkinter
import matplotlib
import numpy as np
import scipy as sp
import IPython
import sklearn
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split

iris_dataset = load_iris()
print("Ключи iris_datasets: \n{}".format(iris_dataset.keys()))
print(iris_dataset['DESCR'][:193] + "\n...")
print("Названия ответов: {}".format(iris_dataset['target_names']))
print("Первые пять строк массива data:\n{}".format(iris_dataset['data'][:5]))
X_train, X_test, y_train, y_test = train_test_split(
iris_dataset['data'], iris_dataset['target'], random_state=0)

# print("X: \n" + format(X_train))

iris_dataframe = pd.DataFrame(X_train, columns=iris_dataset.feature_names)
grr = 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)

Try to do smtng like grr.plot(), there is no mistakes but graphic doesn't appear.. Who's know why?

1 Answer 1

2

It is best to use matplotlib.pyplot for plots

add this to the imports

import matplotlib.pyplot as plt

Then at the very bottom of the file

plt.show()

You can force pandas to do it without importing matplotlib but all you are doing there is finding somewhere that matplotlib has been imported in pandas, and calling the same show function.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.