我需要估计数据中的binc值,但是在应用混淆矩阵时出现错误。 我试图进行类型转换,但失败了。
from sklearn.cross_validation import train_test_split
from xgboost import XGBClassifier
X = tezgah_5.drop(columns=['BINC'])
y = tezgah_5['BINC']
X_train, X_test, y_train, y_test = train_test_split(X,y, test_size =0.30, random_state =42)
xgb_model = XGBClassifier ().fit(X_train,y_train)
y_pred = xgb_model.predict(X_test)
from sklearn.metrics import confusion_matrix
cm= confusion_matrix(y_pred , y_test)
我收到此错误:
C:\Users\meoner\Anaconda3\lib\site-packages\sklearn\preprocessing\label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.
if diff:
Traceback (most recent call last):
File "<ipython-input-115-a9f3bc6bdee6>", line 12, in <module>
cm= confusion_matrix(y_pred , y_test)
TypeError: 'tuple' object is not callable