Showing Error while using train_test_Split method to on Kaggle kernal. Help appreciated










0















Can any one expalin what is the error and how to aviod?
The same code actually works in my Jupyter and Spider environment. Also
I didn't understand why this isn't working on kaggle kernel.



Below is my code.



# 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)


Error Details:



 ---------------------------------------------------------------------------
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'









share|improve this question
























  • Looks like you have encountered this issue. Try updating your scikit-learn, numpy and pandas. Show the dtypes for the df. Are any of the columns of categorical type in pandas DataFrame?

    – Vivek Kumar
    Nov 15 '18 at 7:23












  • I find the solution , I just removed ".values" from my code and it works for me.

    – Ravi Varma
    Nov 17 '18 at 4:18
















0















Can any one expalin what is the error and how to aviod?
The same code actually works in my Jupyter and Spider environment. Also
I didn't understand why this isn't working on kaggle kernel.



Below is my code.



# 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)


Error Details:



 ---------------------------------------------------------------------------
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'









share|improve this question
























  • Looks like you have encountered this issue. Try updating your scikit-learn, numpy and pandas. Show the dtypes for the df. Are any of the columns of categorical type in pandas DataFrame?

    – Vivek Kumar
    Nov 15 '18 at 7:23












  • I find the solution , I just removed ".values" from my code and it works for me.

    – Ravi Varma
    Nov 17 '18 at 4:18














0












0








0


1






Can any one expalin what is the error and how to aviod?
The same code actually works in my Jupyter and Spider environment. Also
I didn't understand why this isn't working on kaggle kernel.



Below is my code.



# 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)


Error Details:



 ---------------------------------------------------------------------------
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'









share|improve this question
















Can any one expalin what is the error and how to aviod?
The same code actually works in my Jupyter and Spider environment. Also
I didn't understand why this isn't working on kaggle kernel.



Below is my code.



# 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)


Error Details:



 ---------------------------------------------------------------------------
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'






python python-3.x scikit-learn kernel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 4:55







Ravi Varma

















asked Nov 15 '18 at 4:30









Ravi VarmaRavi Varma

34




34












  • Looks like you have encountered this issue. Try updating your scikit-learn, numpy and pandas. Show the dtypes for the df. Are any of the columns of categorical type in pandas DataFrame?

    – Vivek Kumar
    Nov 15 '18 at 7:23












  • I find the solution , I just removed ".values" from my code and it works for me.

    – Ravi Varma
    Nov 17 '18 at 4:18


















  • Looks like you have encountered this issue. Try updating your scikit-learn, numpy and pandas. Show the dtypes for the df. Are any of the columns of categorical type in pandas DataFrame?

    – Vivek Kumar
    Nov 15 '18 at 7:23












  • I find the solution , I just removed ".values" from my code and it works for me.

    – Ravi Varma
    Nov 17 '18 at 4:18

















Looks like you have encountered this issue. Try updating your scikit-learn, numpy and pandas. Show the dtypes for the df. Are any of the columns of categorical type in pandas DataFrame?

– Vivek Kumar
Nov 15 '18 at 7:23






Looks like you have encountered this issue. Try updating your scikit-learn, numpy and pandas. Show the dtypes for the df. Are any of the columns of categorical type in pandas DataFrame?

– Vivek Kumar
Nov 15 '18 at 7:23














I find the solution , I just removed ".values" from my code and it works for me.

– Ravi Varma
Nov 17 '18 at 4:18






I find the solution , I just removed ".values" from my code and it works for me.

– Ravi Varma
Nov 17 '18 at 4:18













0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312464%2fshowing-error-while-using-train-test-split-method-to-on-kaggle-kernal-help-appr%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312464%2fshowing-error-while-using-train-test-split-method-to-on-kaggle-kernal-help-appr%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3