完成机器学习教程:
http://machinelearningmastery.com/machine-learning-in-python-step-by-step/
具体而言,第4.2节。不幸的是,我的代码抛出错误
NameError: name 'scatter_matrix' is not defined
这是我的代码:
import pandas
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
url = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
names = ['sepal-length', 'sepal-width', 'petal-length', 'petal-width', 'class']
dataset = pandas.read_csv(url, names=names)
scatter_matrix(dataset)
plt.show()
scatter_matrix上至少有一个Stack Overflow问题,但我无法弄清楚缺少什么。
答案 0 :(得分:1)
你必须像这样导入它:
from pandas.plotting import scatter_matrix
答案 1 :(得分:0)
因为您已导入熊猫。您可以像下面这样使用它:
pd.scatter_matrix(dataset)
不过,pandas.scatter_matrix()
已过时。改用pandas.plotting.scatter_matrix()