gpt4 book ai didi

python - 属性错误 : 'MinMaxScaler' object has no attribute 'clip'

转载 作者:行者123 更新时间:2023-12-04 15:57:45 30 4
gpt4 key购买 nike

当我尝试加载已保存的 sklearn.preprocessing.MinMaxScaler 时出现以下错误

/shared/env/lib/python3.6/site-packages/sklearn/base.py:315: UserWarning: Trying to unpickle estimator MinMaxScaler from version 0.23.2 when using version 0.24.0. This might lead to breaking code or invalid results. Use at your own risk.
UserWarning)
[2021-01-08 19:40:28,805 INFO train.py:1317 - main ] EXCEPTION WORKER 100:
Traceback (most recent call last):
...
File "/shared/core/simulate.py", line 129, in process_obs
obs = scaler.transform(obs)
File "/shared/env/lib/python3.6/site-packages/sklearn/preprocessing/_data.py", line 439, in transform
if self.clip:
AttributeError: 'MinMaxScaler' object has no attribute 'clip'
我在一台机器上训练了缩放器,保存了它,然后将它推送到第二台机器上,在那里它被加载并用于转换输入。
# loading and transforming
import joblib
from sklearn.preprocessing import MinMaxScaler

scaler = joblib.load('scaler')
assert isinstance(scaler, MinMaxScaler)
data = scaler.transform(data) # throws exception

最佳答案

问题是您在 sklearn 版本较旧的机器上训练缩放器,而不是用于加载缩放器的机器。
通知 UserWarningUserWarning: Trying to unpickle estimator MinMaxScaler from version 0.23.2 when using version 0.24.0. This might lead to breaking code or invalid results. Use at your own risk. UserWarning)解决方案是修复版本不匹配。通过将一个 sklearn 升级到 0.24.0或降级到 0.23.2

关于python - 属性错误 : 'MinMaxScaler' object has no attribute 'clip' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65635575/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com