问题背景
使用朴素贝叶斯后,想把列值进行合并,使用numpy.concatenate方法时报错:
TypeError: concatenate() got multiple values for argument ‘axis‘
问题解决
原因是有一列是没有列维度值的,需要使用方法添加一下,目标列的基本情况为
使用reshape方法进行重置
y2_test_predict.reshape(5,1)
最后用合并成功!
# y2_test_predict没有列维度,需要reshape重置一下
test_data_result = np.concatenate(x2_test,y2_test_predict_proba,
y2_test_predict.reshape(5,1),axis=1)
# 格式转换
test_data_result2 = pd.DataFrame(test_data_result)
test_data_result2.head()