【发布时间】:2020-05-21 02:08:31
【问题描述】:
下面是代码,下面是错误。
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=0)
错误:
runfile('C:/Users/HP/Desktop/Python/P14-Machine-Learning-AZ-Template-Folder/Machine Learning A-Z Template Folder/Part 1 - Data Preprocessing/data_preprocessing_template.py', wdir='C:/Users/HP/Desktop/Python/P14-Machine-Learning-AZ-Template-Folder/Machine Learning A-Z Template Folder/Part 1 - Data Preprocessing')
Traceback (most recent call last):
File "C:\Users\HP\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3326, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-44-136d41c04781>", line 1, in <module>
runfile('C:/Users/HP/Desktop/Python/P14-Machine-Learning-AZ-Template-Folder/Machine Learning A-Z Template Folder/Part 1 - Data Preprocessing/data_preprocessing_template.py', wdir='C:/Users/HP/Desktop/Python/P14-Machine-Learning-AZ-Template-Folder/Machine Learning A-Z Template Folder/Part 1 - Data Preprocessing')
File "C:\Users\HP\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\HP\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/HP/Desktop/Python/P14-Machine-Learning-AZ-Template-Folder/Machine Learning A-Z Template Folder/Part 1 - Data Preprocessing/data_preprocessing_template.py", line 35
X-train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,random_state=0)
^
SyntaxError: can't assign to operator
【问题讨论】:
-
你为什么使用 X-train ?不应该是 X_train 吗?
-
请添加您的案例、问题、您尝试过的解决方案以及您搜索的解决方案的描述