简体   繁体   English

KeyError:“['features'] 在轴中找不到”

[英]KeyError: "['features'] not found in axis"

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?这是另一个错误,当我尝试使用 Python 中的 KNN model 将平衡数据集分成 80% 和 20% 的训练和测试集时。下面给出的错误是什么意思?

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如何计算变量 x 和 y
  • How to decide which columns to drop如何决定删除哪些列

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.该错误意味着此 ['features'] 未作为列创建到您的数据集中,我无法弄清楚您从数据集中选择的功能和目标是什么。 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我可以给你看一个例子:一个数据集,它的列名是 id、qid1、qid2、ques1、ques2、is_duplicated 所以正确的代码可以定义你想要预测的特征和目标

features = ['qid1','qid2','question1','question2'] target = raw_df.drop(features,axis =1) 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此代码意味着您选择一些列作为特征,从您的数据中删除这些列,然后 rest 列成为目标

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 KeyError:“['Date'] 在轴中找不到”? - KeyError: "['Date'] not found in axis"? KeyError:在轴中找不到“[&#39;class&#39;]” - KeyError:"['class']" not found in axis KeyError:删除带有熊猫的行时出现“ []在轴上找不到” - KeyError: “[] not found in axis” while dropping row with pandas 发生异常:在轴中找不到 KeyError - Exception has occurred: KeyError not found in axis df.rename(columns) 返回 KeyError: ..values.. not found in axis" - df.rename(columns) returns KeyError: ..values.. not found in axis" KeyError:在 pd.DataFrame.drop() 期间未在 Axis 中找到 - KeyError: Not Found in Axis during pd.DataFrame.drop() 无法删除日期列 KeyError: &quot;[&#39;Date&#39;] not found in axis - Can't drop a Date column KeyError: "['Date'] not found in axis 在 spyder 中运行的代码给出了一个 KeyError: not found in axis&#39; on the server - The code running in spyder gives a KeyError: not found in axis' on the server keyerror:“['label'] not found in axis”,使用 python 时,即使在提供 axis = 1 和 inplace = True 之后 - keyerror: "['label'] not found in axis", while using python, even after providing axis = 1 and inplace = True 如何修复删除列时在轴中找不到 [] 的键错误,如何使用 pandas 修复此问题? - How to fix keyerror of [] not found in axis while dropping columns, how to fix this with pandas?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM