当我输入这段代码
print(cross_val_score(model, X, y, cv=3))
返回错误,读取name 'model' is not defined
:
print(cross_val_score(model, X, y, cv=3))
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
/var/folders/b7/ltdcsdbx0ds1pftc_qmt_k900000gn/T/ipykernel_32984/4204694188.py in <module>
----> 1 print(cross_val_score(model, X, y, cv=3))
NameError: name 'model' is not defined
如果在像Jupyter这样的编辑器中逐单元运行代码,则需要确保运行了定义每个元素所需的所有单元您将在您要运行的行中使用。