Search code examples
oversamplingimblearnsmote

TypeError: __init__() got an unexpected keyword argument 'ratio' when using SMOTE


I am using SMOTE to oversample as my dataset is imbalanced. I am getting an unexpected argument error. But in the documentation, the ratio argument is defined for SMOTE. Can someone help me understand where I am going wrong?

Code snippet

from imblearn.over_sampling import SMOTE
sm = SMOTE(random_state=42, ratio=0.6)

Error

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

Solution

  • Try replacing the 'Ratio' with 'sampling_strategy' :

    from imblearn.over_sampling import SMOTE
    
    sm = SMOTE(random_state=42, sampling_strategy=0.6)