0

This is another error when I am trying to split the balanced dataset into training and test set by 80% and 20% using the KNN model in Python. What is meant by the error given below?

y = ["TCGA.22.5482.LUSC.C1"]
x = Combined_data_df.drop(['features'],axis=1)

**KeyError**       Traceback (most recent call last)
<ipython-input-68-9ee94240e101> in <module>
      1 y = ["TCGA.22.5482.LUSC.C1"]
----> 2 x = Combined_data_df.drop(['features'],axis=1)
    
**KeyError: "['features'] not found in axis"**

What is meant by this error?

  • How to work out the variables x and y
  • How to decide which columns to drop
khelwood
  • 55,782
  • 14
  • 81
  • 108
dkareer
  • 13
  • 6

1 Answers1

0

The error mean this ['features'] not founded as column into your dataset, I can not figure out what is your features and target you choose from your data set. I can show you an example: A dataset it's column names id, qid1, qid2, ques1, ques2, is_duplicated so the right code to defined which features and target you want to predict

features = ['qid1','qid2','question1','question2'] target = raw_df.drop(features,axis =1)

this code mean you choose some columns as feature, from your data delete these columns then rest of columns become target

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 17 '22 at 23:59