如何绘制特征变化

时间:2019-05-19 13:19:40

标签: python plot

我有2列的数据集,我想显示一个特征根据二进制输出值的变化

数据

id      Column1     output
1          15          0
2          80          1
3         120          1
4          20          0
...       ...         ...

我想用python绘制一个图,其中x轴包含Column1的值,y轴包含获得正值的百分比。

我已经知道情节的形式具有指数函数的形式,当column1的数字较小时,我将得到更多的正输出,而当它的值较长时将得到正输出

2 个答案:

答案 0 :(得分:0)

# you need to import the pyplot class from the matplotlib module
import matplotlib.pyplot as plt

# use plot methode
# plt.plot(list of x-axis points, list of y-axis points) 
plt.plot([15,80,120,20], [0,1,1,0])

# set x-axis begin, end and y-axis begin, end. 
plt.axis([0, 200, 0, 1])

# use the show method. 
plt.show()

答案 1 :(得分:0)

指数图可能需要两个这样的列表 试试这个

import matplotlib.pyplot as plt

# x-axis points list
xL = [5,10,15,20,25,30]

# y-axis points list
yL = [100,50,25,12,10]

plt.plot(xL, yL)

plt.axis([0, 35, 0, 200])
plt.show()