Error at Standardization/Normalization

While following the ‘Handling Imbalanced Classes’ notebooks for Week 2 of Starting with Data Science Bootcamp, I executed the code for scaling the data using StandardScaler.

But I am getting the following error -
ValueError: Expected 2D array, got 1D array instead:
array=[96.60480238 3.39519762].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

Can someone help me out, I have attached the screenshot of my code for reference.

Hi @anshmjn01
Please go through this: python - SVR Model -->Feature Scaling - Expected 2D array, got 1D array instead - Stack Overflow
Let me know if you are able to solve it.

I clicked on “Run all Cells” and now it has been executed successfully

When balancing the classes, I am getting another error while generating synthetic samples.
It says that SMOTE has no attribute “fit_sample”.
The sklearn version is also 0.24.1 (as suggested on StackOverflow).

I have attached the screenshot of the same.

Hi @anshmjn01

Try fit_resample()

It’s working thanks @manish_kc_06