gpt4 book ai didi

python - 如何在imblearn中使用比率= 'dict'的随机欠采样器?

转载 作者:行者123 更新时间:2023-12-03 08:01:38 36 4
gpt4 key购买 nike

我正在尝试使用imblearn的random under-sampler处理不平衡的数据集。我想指定要手动欠采样的标签数量。这是我的代码:

sm = RandomUnderSampler(ratio = {0:142498, 1: 495}, random_state=42)
X_train, y_train = sm.fit_sample(X_tr,encoded_Ytrain)
print(format(Counter(y_train)))

但是,这将引发错误:

File "first_approach.py", line 56, in < module > X_train, y_train = sm.fit_sample(X_tr,encoded_Ytrain) raise ValueError('Unknown parameter type for ratio.') ValueError: Unknown parameter type for ratio.



传递相同的正确语法应该是什么?

最佳答案

根据您使用的版本,使用字典时必须使用“sampling_strategy”来代替“比率”。

关于python - 如何在imblearn中使用比率= 'dict'的随机欠采样器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44724895/

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