sns.lmplot(x= , y= , data= ,hue= , fit_reg=True/False....)
参数说明:
x/y=... : 是指定画图时的x坐标是啥,y是啥,这里不是将其命名,而是指出以什么参数为x、y轴 ;一般是某一个“属性”,即特征
························································································································
data= :这里指定数据,并且数据一定要是DataFrame结构
这里就涉及到将load_或者fetch获得的数据结构进行变化:
Data_load=pd.DataFrame(data["data"],columns=data.feature_names)
··························································································································
hue= :这里是指按照什么进行分类,
data【“data”】获取的数据一般是这样的:
一般我们把它再加一列,就是将每个样本的目标值,即标签加入进去
Data_load["target"]=data.target
所以这里的hue一般这样写:
hue=Data_load.target或者["target"]
··························································································································
fit_reg=T/F:是否进行线性拟合
整体代码:
# 将数据用seaborn库进行可视化
data_1=pd.DataFrame(data=dataSet1["data"],columns=dataSet1.feature_names)
data_1["target"]=dataSet1.target
print(data_1)
print(data_1.columns[0])
sns.lmplot(x=data_1.columns[0], y=data_1.columns[1], data=data_1, hue="target")
plt.xlabel("cols1")
plt.ylabel("cols2")
plt.title("鸢尾花")
plt.show()
结果:
注意图的相关显示的属性,如x坐标名称,y坐标名称,图的题目等是同matplotlib那个一样,都是 “plt.xxx”
最后的展示也是“plt.show()”