train_test_split() got an unexpected keyword argument 'n_samples'
时间: 2023-10-13 17:07:24 浏览: 128
The error message suggests that you are passing an unexpected keyword argument 'n_samples' to the train_test_split() function.
train_test_split() function does not have an argument called 'n_samples'. Instead, it has an argument called 'test_size' that specifies the proportion of the dataset to include in the test split.
Make sure that you are using the correct argument names and values when calling the train_test_split() function. If you are still having trouble, please provide more information about your code and the specific error you are encountering.
相关问题
train_test_split() got an unexpected keyword argument 'Shuffle'
The error message suggests that the `train_test_split()` function is receiving an unexpected keyword argument `Shuffle`. This could happen if you misspelled the argument name or if the argument is not supported by the version of the function you are using.
In scikit-learn's `train_test_split()` function, the argument for shuffling the data is `shuffle` (lowercase "s") and it is a boolean value. Therefore, you should change `Shuffle` to `shuffle` in your code.
Here is an example of how to use `train_test_split()` with shuffling:
```python
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, shuffle=True)
```
Make sure that you have the latest version of scikit-learn installed to avoid any potential compatibility issues.
X_train, X_test, y_train, y_test = train_test_split(sequences, labels, test_size=0.2, random_state=42,Shuffle=False)报错train_test_split() got an unexpected keyword argument 'Shuffle'
这个错误是因为`train_test_split()`函数中没有`Shuffle`这个参数。相反,它应该是`shuffle`(小写字母)。所以,你需要将`Shuffle=False`修改为`shuffle=False`。
正确的代码应该是这样的:
```
X_train, X_test, y_train, y_test = train_test_split(sequences, labels, test_size=0.2, random_state=42, shuffle=False)
```
这将确保你的数据集不会在分割时被随机打乱。
阅读全文