Cannot create CustomScaler
Hi,
I have tried multiple ways of writing and running the code from this lecture. After some time, I decided to check, if it will work if I simply run the notebook attached to one of the next lectures, that contains this code. However, in all cases I get an error when creating
absenteeism_scaler = CustomScaler(columns_to_scale)
Here is the full error message:
TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_10984/570332649.py in <module>
1 # declare a scaler object, specifying the columns you want to scale
----> 2 absenteeism_scaler = CustomScaler(columns_to_scale)
~\AppData\Local\Temp/ipykernel_10984/2373505308.py in __init__(self, columns, copy, with_mean, with_std)
17
18 # scaler is nothing but a Standard Scaler object
---> 19 self.scaler = StandardScaler(copy,with_mean,with_std)
20 # with some columns 'twist'
21 self.columns = columns
TypeError: __init__() takes 1 positional argument but 4 were given
Any idea, what is wrong?
Hi Hubert!
Thanks for reaching out.
Can you please confirm that columns_to_scale
contains 1:1 the same data as the one used in the videos?
If not, please ensure it does and retry!
Hope this helps but please feel free to get back to us should you need further assistance. Thank you.
Best,
Martin
Hello, I am encountering the same problem. I used exactly the same code and the same preprocessed dataset "Absenteeism_preprocessed.csv" used in the lecture. There is obviously a problem with the CustomScaler function I coudn't understand
Could you please check this out?
Thank you.
Best Regards,
Sofiane
Hi Sofiane!
Thanks for reaching out.
This error stems from the code you've executed previously in your *.ipynb file. We are aware that this may mean that you have made one of potentially a number of errors, but it is not exactly so. From the screenshot you've shared, it seems that you may have not created the columns_to_scale in the way shown in the course. Therefore, can you please revise/restart the kernel and re-run all cells in the suggested order, to ensure that this variable contains the relevant content?
Looking forward to your answer.
Best,
Tsvetelin
If you are still having this __init__() takes 1 positional argument issue, refer to this solution link https://365datascience.com/q/453f655355 by Karen Harutyunyan.
Hi Okafor!
Thanks for reaching out!
Indeed, Karen did provide an alternative solution one may want to check in case of having difficulties with the one provided in the course. In the meantime, please don't forget you can always post a question in the Q&A, we'll be glad to help.
Kind regards,
Martin