0
試圖實現XGBoost來確定最重要的變量,我有一些數組的錯誤。類型str沒有定義__round__方法錯誤
我的完整代碼如下
from numpy import loadtxt
from numpy import sort
import pandas as pd
from xgboost import XGBClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.feature_selection import SelectFromModel
df = pd.read_csv('data.txt')
array=df.values
X= array[:,0:330]
Y = array[:,330]
X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.33, random_state=7)
model = XGBClassifier()
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
predictions = [round(value) for value in y_pred]
,我得到以下錯誤:
TypeError: type str doesn't define __round__ method
我能做些什麼?
如果您可以發佈整個錯誤消息 – 0TTT0