Scatter_Matrix 不会显示使用 Pandas 和
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44596270/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Scatter_Matrix Will Not Display Using Pandas and
提问by HMLDude
Working through following the Machine Learning Tutorial:
遵循机器学习教程:
http://machinelearningmastery.com/machine-learning-in-python-step-by-step/
http://machinelearningmastery.com/machine-learning-in-python-step-by-step/
Specifically, Section 4.2. Unfortunately, my code is throwing an error
具体来说,第 4.2 节。不幸的是,我的代码抛出了错误
NameError: name 'scatter_matrix' is not defined
Here is my code:
这是我的代码:
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()
There's at least one Stack Overflow question on scatter_matrix, but I haven't able to figure out what's missing.
至少有一个关于 scatter_matrix 的 Stack Overflow 问题,但我无法弄清楚缺少什么。
回答by Jan Trienes
You will have to import it like this:
您必须像这样导入它:
from pandas.plotting import scatter_matrix