我的代码是:
undersample = TomekLinks(sampling_strategy='majority', n_jobs= -1, random_state = 42)
X_tl, y_tl = undersample.fit_resample(X, y)当我运行它时,我会得到以下错误:
TypeError: __init__() got an unexpected keyword argument 'random_state'我的包裹版本是:
imbalanced-learn==0.9.0尽管在文档中存在此参数:
random_state : int,RandomState实例或无,可选(default=None)
当我在_tomek_links.py中检查构造函数时,我没有看到随机状态字段:
@_deprecate_positional_args
def __init__(self, *, sampling_strategy="auto", n_jobs=None):
super().__init__(sampling_strategy=sampling_strategy)
self.n_jobs = n_jobs发布于 2022-03-24 14:44:46
我想你看错文件了。该参数用于版本0.3.0-dev,因此我选中了:sampling.TomekLinks.html --该参数已在较新的0.9.0版本中被废弃。
此外,如文档所示,似乎必须在make_classification函数中指定它,如下所示:
X, y = make_classification(n_classes=2, class_sep=2,
weights=[0.1, 0.9],
n_informative=3, n_redundant=1,
flip_y=0, n_features=20,
n_clusters_per_class=1,
n_samples=1000, random_state=10
)https://stackoverflow.com/questions/71604064
复制相似问题