Last answered:

06 Mar 2024

Posted on:

21 Jun 2023

0

Different result

When I created dummy variables as shown in the video lecture, I got results slightly different than yours. The difference is that I got True or False instead of 0 and 1s. Could you help me to fix this issue? Thanks beforehand

4 answers ( 0 marked as helpful)
Instructor
Posted on:

03 Jul 2023

0

Hey Nijat,


Thank you for reaching out and apologies for the late reply!


Could you please provide a screenshot of the code you are using to create the dummies as well as the output?


If you run the notebook provided in the resources (called "Linear Regression Practical Example (Part 3) Notebook.ipynb"), do you obtain the same result?


Kind regards,

365 Hristina

Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Posted on:

07 Oct 2023

0

Here is the screenshot and yes, the result is the same when we run  "Linear Regression Practical Example (Part 3) Notebook.ipynb" in our PC.

Instructor
Posted on:

09 Oct 2023

1

Hey Harsh,


Thanks for reaching out.


I've now seen where the discrepancy comes from. Go to pandas' documentation:

https://pandas.pydata.org/pandas-docs/version/1.5/reference/api/pandas.get_dummies.html#:~:text=dtypedtype%2C%20default%20np.uint8

In the top right corner, next to the magnifying glass, you will find the option to study the documentation for previous versions.



If you select versions 1.5 and older, you will see that the default data type of the new columns is np.uint8 which stands for a "NumPy 8-bit unsigned integer number". As of versions 2.0 and newer, the default data type for these new columns is a Boolean instead. Therefore, the difference between the outputs in the lecture and in your notebook stems from different versions of the pandas library.


Hope this helps!


Kind regards,

365 Hristina

Posted on:

06 Mar 2024

0

Hi,


data_with_dummies_int = data_with_dummies.astype(int)

just use this to get true as 1 and false as 0.
hope this helps...

Submit an answer