0
$\begingroup$
Cell In[24], line 5
      2 from mlxtend.feature_selection import SequentialFeatureSelector as sfs
      3 #from sklearn.linear_model import LogisticRegression
      4 #from sklearn.model_selection import train_test_split 
----> 5 X_train, X_test, y_test = train_test_split('iv','dv', test_size=0.25, stratify = dv)
      7 logreg = linear_model.LogisticRegression()
      8 #logreg.fit(X_train, y_train['binary_num'])
$\endgroup$

1 Answer 1

1
$\begingroup$

As you can see in the documentation, the data provided to train_test_split need to be arrays of data (e.g. numpy arrays or pandas dataframe), not strings. If your data is stored in the iv and dv variables, the correct way to call the function would be as follows:

X_train, X_test, y_test = train_test_split(iv, dv, test_size=0.25, stratify = dv)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.