简体   繁体   English

Jupyter notebook 在使用 MinMaxScalar 或 StandardScalar 时出错?

[英]Jupyter notebook is giving error when using MinMaxScalar or StandardScalar?

When performing StandardScalar or MinMaxScalar using PythonAdv kernel the jupyter notebook is printing error.使用 PythonAdv kernel 执行 StandardScalar 或 MinMaxScalar 时,jupyter notebook 打印错误。 However, when using Python 3 environment the same jupyter note book is working fine:但是,当使用 Python 3 环境时,同一个 jupyter 笔记本工作正常:

from sklearn.preprocessing import MinMaxScaler

# Scale X values
X_scalar = MinMaxScaler().fit(X_train)
#print(X_scalar)
X_train_scaled = X_scaler.transform(X_train)
X_test_scaled = X_scaler.transform(X_test)

Error:错误:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-e5dc00a586d3> in <module>
      4 X_scalar = MinMaxScaler().fit(X_train)
      5 #print(X_scalar)
----> 6 X_train_scaled = X_scaler.transform(X_train)
      7 X_test_scaled = X_scaler.transform(X_test)

NameError: name 'X_scaler' is not defined

I have Anaconda 3, python 3.6 and PythonAdv environments on Git Bash on Windows. I have Anaconda 3, python 3.6 and PythonAdv environments on Git Bash on Windows.

from sklearn.preprocessing import MinMaxScaler

# Scale X values
X_scaler = MinMaxScaler().fit(X_train)
#print(X_scalar)
X_train_scaled = X_scaler.transform(X_train)
X_test_scaled = X_scaler.transform(X_test)

There is a small typo.有一个小错字。 you define X_scalar then use X_scaler.您定义 X_scalar 然后使用 X_scaler。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jupyter notebook 给了我正确代码的错误 - Jupyter notebook is giving me error for correct codes 在 Jupyter Notebook 中使用 rioXarray 时出错 - Error using rioXarray in Jupyter Notebook 使用 jupyter notebook 运行代码时出现 argparse 错误 - Error in argparse when running the code using jupyter notebook 使用Jupyter Notebook将CSV文件加载到数据框时出现错误 - Getting error when loading CSV file to dataframe using Jupyter notebook 使用 Jupyter notebook 命令进入 pycharm 时的关键错误 5 问题 - Key error 5 issue when using Jupyter notebook commands into pycharm 当我尝试导入 jupyter notebook(使用 venv)时,安装的包给出了“ModuleNotFoundError” - Installed package giving "ModuleNotFoundError" when I try to import into jupyter notebook (using venv) Bash电池魔术(%%)在Jupyter笔记本(Windows 7)中给出“找不到命令”错误 - Bash cell magic (%%) giving “command not found” error in Jupyter notebook (Windows 7) SQL Persist 命令在 IBM Watson Studio Jupyter Notebook 中出现错误 - SQL Persist command is giving an Error in IBM Watson studio Jupyter Notebook 尝试启动 Jupyter 笔记本时出现 DLL 错误 - DLL Error when trying to launch Jupyter notebook 加载 Jupyter Notebook 扩展时导入错误 - Import error when loading Jupyter Notebook Extensions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM