Код: Выделить всё
import pandas as pd
import numpy as np
import xgboost as xgb
from sklearn.model_selection import train_test_split
df=pd.read_csv('442.csv')
y=df.columnone
X=df.columnfive
X_train,X_test,Y_train,Y_test=train_test_split(X,y,test_size=0.2)
dtrain = xgb.DMatrix(X_train, label=Y_train)
dtest = xgb.DMatrix(X_test, label=Y_test)
Код: Выделить всё
X_train.shape
>(405020,)
Y_train.shape
>(405020,)
param = {
'eta': 0.3,
'max_depth': 3,
'objective': 'multi:softprob',
'num_class': 2}
steps = 20 # The number of training iterations
Код: Выделить всё
model = xgb.train(param, dtrain, steps)
>XGBoostError: Check failed: labels_.Size() == num_row_ (405020 vs. 1) : Size of labels must equal to number of rows.
Код: Выделить всё
dtrain.num_row()
>1
dtrain.num_col()
>405020
Подробнее здесь: https://stackoverflow.com/questions/627 ... er-of-rows
Мобильная версия