Ошибка при использовании метода train_test_Split для Kaggle kernal.Помощь оценена - PullRequest
0 голосов
/ 15 ноября 2018

Может кто-нибудь объяснить, в чем ошибка и как aviod?Тот же самый код фактически работает в моей среде Jupyter и Spider.Также я не понял, почему это не работает в ядре kaggle.

Ниже приведен мой код.

# Prepare X and y objects for sikitlearn
X = df.iloc[:, 1:5].values
y = df.iloc[:,-1].values

# Splitting the Dataset into the training set and the test set
X_train, X_test, y_train, y_test = train_test_split(X,y, test_size = 0.3, random_state =4)

Сведения об ошибке:

        ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)

<ipython-input-49-5647b5a0596a> in <module>()
      1 # Splitting the Dataset into the training set and the test set
      2 from sklearn.model_selection import train_test_split
----> 3 X_train, X_test, y_train, y_test = train_test_split(X,y, test_size = 0.3, random_state =4)

/opt/conda/lib/python3.6/site-packages/sklearn/model_selection/_split.py in train_test_split(*arrays, **options)
   2100 
   2101     return list(chain.from_iterable((safe_indexing(a, train),
-> 2102                                      safe_indexing(a, test)) for a in arrays))
   2103 
   2104 

/opt/conda/lib/python3.6/site-packages/sklearn/model_selection/_split.py in <genexpr>(.0)
   2100 
   2101     return list(chain.from_iterable((safe_indexing(a, train),
-> 2102                                      safe_indexing(a, test)) for a in arrays))
   2103 
   2104 

/opt/conda/lib/python3.6/site-packages/sklearn/utils/__init__.py in safe_indexing(X, indices)
    183                                    indices.dtype.kind == 'i'):
    184             # This is often substantially faster than X[indices]
--> 185             return X.take(indices, axis=0)
    186         else:
    187             return X[indices]

TypeError: take_nd() got an unexpected keyword argument 'axis'

1 Ответ

0 голосов
/ 08 августа 2019

Возможно, из-за того, что тип целевой переменной не категориален, вы должны изменить ее на метки.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...