Flash Sale: Flat 70% + Addl. 25% Off on all Courses | Use Coupon DS25 in Checkout | Offer Expires In

  Enroll Now

Feature Scaling

Since most of our data has already been scaled, we should scale the columns that are not yet scaled (Amount and Time).

We shall use StandardScaler to scale the "Amount" column and the "Time" column.

INSTRUCTIONS
  • From sklearn.preprocessing import StandardScaler

    from sklearn.preprocessing import StandardScaler
    
  • Get StandardScaler() instances.

    scaler_amount = StandardScaler()
    scaler_time = StandardScaler()
    
  • Use fit_transform of scaler_amount on the X_train['Amount'] and save the transformed values in X_train['normAmount'].

    X_train['normAmount'] = scaler_amount .<< your code comes here >>(X_train['Amount'].values.reshape(-1, 1))
    
  • Use transform of scaler_amount on the X_test['Amount'] and save the transformed values in X_test['normAmount'].

    X_test['normAmount'] = scaler_amount .<< your code comes here >>(X_test['Amount'].values.reshape(-1, 1))
    
  • Use fit_transform of scaler_time on the X_train['Time'] and save the transformed values in X_train['normTime'].

    X_train['normTime'] = scaler_time .<< your code comes here >>(X_train['Time'].values.reshape(-1, 1))
    
  • Use transform of scaler_time on the X_test['Time'] and save the transformed values in X_test['normTime'].

    X_test['normTime'] = scaler_time .<< your code comes here >>(X_test['Time'].values.reshape(-1, 1))
    
  • Drop Time and Amount columns from X_train and X_test.

    X_train = X_train.drop(['Time', 'Amount'], axis=1)
    X_test = X_test.drop(['Time', 'Amount'], axis=1)
    
  • Display the top 5 rows of X_train.

    X_train.head()
    

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...