TypeError: train_test_split() got an unexpected keyword argument 'randon_state'
时间: 2023-11-02 10:33:07 浏览: 156
The error message suggests that you have a typo in your code: "randon_state" should be "random_state", with a "m" instead of a "n". The "random_state" parameter is used to control the random seed used by the train_test_split function. Here's an example of how to use it correctly:
```
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
```
In this example, the "random_state" parameter is set to 42, which means that the same random seed will be used every time the code is run. This ensures that the train-test split is reproducible.
相关问题
TypeError: train_ch3() got an unexpected keyword argument 'eval_train'
这错误提示通常是因为train_ch3()函数的参数列表中没有eval_train这个参数名,而你在调用函数时使用了这个参数名。你需要检查一下train_ch3()函数的定义,确保函数参数列表中包含了eval_train这个参数名,并且参数名的拼写没有错别字。如果确实没有这个参数名,那么你需要修改调用函数的代码,将eval_train这个参数名改成函数参数列表中存在的参数名。
TypeError: __init__() got an unexpected keyword argument 'split'
当出现"TypeError: __init__() got an unexpected keyword argument 'split'"错误提示时,这意味着在调用某个函数或方法时,传入了不被支持的关键字参数'split'。这个错误通常发生在使用Python时,可能是因为你在使用的库或模块中的某个函数或方法不支持'split'这个参数。要解决这个问题,你可以检查你代码中的函数或方法调用,并确保你传入的关键字参数是被支持的。如果你不确定哪个函数或方法引起了这个错误,你可以查看错误提示中提供的详细信息,看看哪个函数或方法出现了这个问题,然后查阅相关文档或搜索引擎,了解该函数或方法是否支持'split'参数。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Python出现TypeError: __init__ got an unexpected keyword argument ‘autocompletion‘错](https://blog.csdn.net/ai52learn/article/details/130995288)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [TypeError:__init__() got an unexpected keyword argunent ‘executable_path‘解决方案](https://blog.csdn.net/weixin_43178406/article/details/131459762)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]