Halloween Sale: Flat 70% + Addl. 25% Off + 30 Days Extra Lab on all Courses | Use Coupon HS25 in Checkout | Offer Expires In

  Enroll Now

Applying SMOTE technique

We shall apply the SMOTE technique only on train data and keep the test data untouched so as to avoid any form of data leakage.

INSTRUCTIONS
  • From imblearn.over_sampling import SMOTE.

    from imblearn.over_sampling import SMOTE
    
  • Print the number of class-wise samples before over-sampling using the value_counts method on y_train.

    print("Before over-sampling:\n", y_train['Class'].<< your code comes here >>)
    
  • Declare an instance of SMOTE as sm.

    sm = SMOTE()
    
  • Use fit_sample method of sm on X_train and y_train['Class'] and store the resampled features and labels in X_train_res and y_train_res respectively.

    X_train_res, y_train_res = sm.<< your code comes here >>(X_train, y_train['Class'])
    
  • Print the number of class-wise samples after over-sampling using the value_counts method on y_train.

    print("After over-sampling:\n", y_train_res.<< your code comes here >>)
    

No hints are availble for this assesment

Answer is not availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...