import numpy as np
import matplotlib.pyplot as plt
returnMat=np.array([[1,2],[3,4]])
fig=plt.figure()
ax=fig.add_subplot(111)
#ax.scatter(returnMat[:,1],returnMat[:,2])
#绘制颜色,大小不同的点
classLabelVector=[1,2]
ax.scatter(returnMat[:,1],returnMat[:,2],15.0*
array(classLabelVector),15.0*array(classLabelVector))
plt.show()
样例2:
#-*- coding=UTF-8 -*-
#adaboost 算法
import numpy as np
def loadSimpleData():
datMat = np.matrix([[1., 2.1],
[2., 1.1],
[1.3, 1.],
[1., 1.],
[2., 1.]])
classLabels = [1.0, 1.0, -1.0, -1.0, 1.0]
return datMat, classLabels
dataMat,classLabels=loadSimpleData()
c=np.hstack((dataMat,np.mat(classLabels).T))
b=[examle[:2] for examle in np.array(c) if examle[2]==1.0]
b=np.array(b)
print b[:,1]
d=[examle[:,:2] for examle in c if examle[:,2]==-1.0]
e=np.array(d)
e= np.array(e.reshape(2,2))
import numpy as np
import matplotlib.pyplot as plt
returnMat=np.array([[1,2],[3,4],[5,6]])
fig=plt.figure()
ax=fig.add_subplot(111)
#ax.scatter(returnMat[:,1],returnMat[:,2])
#绘制颜色,大小不同的点
ax.scatter(b[:,0],b[:,1],14)
ax.scatter(e[:,0],e[:,1],13)
plt.show()