TypeError: __init__() got an unexpected keyword argument 'random_state'

6.9k Views Asked by At

I tried to handle imbalanced dataset using imblearn as:

nm = NearMiss(random_state=42)
X_bal,Y_bal = nm.fit_sample(x,y)

But I am getting an unexpected error:

TypeError: __init__() got an unexpected keyword argument 'random_state'

How to fix this problem?

Thanks!

1

There are 1 best solutions below

0
On

we first import:

from imblearn import under_sampling as us

us.NearMiss(
    *,
    sampling_strategy='auto',
    version=1,
    n_neighbors=3,
    n_neighbors_ver3=3,
    n_jobs=None,
)

you have use this keyword/parameters in the .__init__()

so to your problem:

NearMiss custuctor dont take random_state as a parameter wich gives you that the init dont expect that as a keyword.