def test(fName, features, nRows):
with open('bin/train.bin') as f:
test = np.load(f)
x = np.mat(test[:nRows,timbreVector[features[0]]]).reshape(nRows,1)
y = np.mat(test[:nRows,timbreVector[features[1]]]).reshape(nRows,1)
z = np.mat(test[:nRows,timbreVector[features[2]]]).reshape(nRows,1)
X = np.concatenate((x, y, z), axis=1)
Y = test[:nRows,0]
pred = predict(fName, X)
print "Mean Square Error: ", np.mean(0.5*np.square(pred - Y))
print "Absolute Error: ", np.mean(np.absolute(pred-Y))
plt.scatter(Y, pred-Y, marker='o')
plt.xlabel('Actual')
plt.ylabel('Difference')
plt.show()
classify.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录