【发布时间】:2022-01-06 03:49:09
【问题描述】:
我有以下代码 sn-p:
df = pd.read_csv("data.csv")
X = df.drop(['label'], axis=1)
Y= df['label']
le = LabelEncoder()
Y = le.fit_transform(Y)
mapping = dict(zip(le.classes_, range(len(le.classes_))))
x_train, x_test, y_train, y_test = train_test_split(X, Y, test_size=0.33, random_state=7,stratify=Y)
##xgb model
model = XGBClassifier()
model.fit(x_train, y_train)
#predict
y_pred = model.predict(x_train)
这里y_pred 给出了编码标签。编码前如何获取真实标签?
【问题讨论】:
标签: python scikit-learn label-encoding