iris data set visualization python

load dataset

import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
iris = pd.read_csv('iris.csv')
iris.head()

insert image description here

Python draws a scatterplot matrix:

show the relationship between two features

sns.set(style='ticks')
sns.pairplot(iris,vars=['sepal_length','petal_length','sepal_width','petal_width'])

insert image description here

Python draws parallel coordinates diagram

data = np.array(iris[['sepal_length','petal_length','sepal_width','petal_width']]).tolist()
parallel_axis = [
    {
    
    "dim":0,"name":"萼片长度"},
    {
    
    "dim":1,"name":"萼片宽度"},
    {
    
    "dim":2,"name":"花瓣长度"},
    {
    
    "dim":3,"name":"花瓣宽度"}
]
parallel = Parallel(init_opts=opts.InitOpts(width="800px",height="600px"))
parallel.add_schema(schema=parallel_axis)
parallel.add('iris平行图',data=data,linestyle_opts=opts.LineStyleOpts(width=2,opacity=0.2))
parallel.render_notebook()

insert image description here

Guess you like

Origin blog.csdn.net/weixin_56260304/article/details/127895313