TypeError: train_test_split() got an unexpected keyword argument 'randon_state'
时间: 2023-11-02 17:33:07 浏览: 378
TypeError: Unexpected keyword argument passed to optimizer: learning_rate 解决方法
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.
阅读全文