Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull request #26

Open
pdxrod opened this issue Jul 1, 2021 · 16 comments
Open

Pull request #26

pdxrod opened this issue Jul 1, 2021 · 16 comments

Comments

@pdxrod
Copy link

pdxrod commented Jul 1, 2021

I'm trying to do a pull request for some files which I've added to this project. They are the Python files Chapter..N...py broken down into smaller files to make them easier to read. I couldn't see how to do a pull request unless I had write access to this repo, so I cloned, and created my own, at https://github.com/pdxrod/practical-statistics-for-data-scientists. I'll delete this repo if requested to do so by Peter Gedeck.

The main purpose of this branch (small-files) was to make it easier for me to read the book and understand it, being able to see the code in smaller sections, whereas the Chapter..N...py files are 395 lines on average.

@gedeck
Copy link
Owner

gedeck commented Jul 1, 2021

Thank you for the contribution. I'm reluctant to add it to the repository in the current form. However, we may come up with a way to do it. I have a second, private repository in addition to the public repository. The private repository contains only the note books and contains some additional code to create the figure files that were used for the book. Whenever I make changes to the code, I modify the private repository and then run a script that takes the note book, strips out the code that is book specific, creates notebooks and code files and runs each of them. On success, the files are copied to the public repository. This has the advantage, that I only need to update one file and create all of the others automatically. This is the reason why I would like to keep the R and Python directory und my full control.

Coming back to your suggestion. What we could do is have a contrib directory where we add code contributed by the community. This could be something like your contribution or variations of the code using different packages (e.g. ggplot and not base-R plotting, or building models in scikit-learn using pipelines). I would not take responsibility for maintaining the code in this directory.

What do you think of this?

@pdxrod
Copy link
Author

pdxrod commented Jul 1, 2021 via email

@gedeck
Copy link
Owner

gedeck commented Jul 1, 2021

There is no need to have write access. Instead of creating a new repository, you fork this one and make changes in the forked repository. You can then create a pull request from your forked repository into mine. Here is a screenshot that should explain how the fork can create a pull request to the original repository.
image

@pdxrod
Copy link
Author

pdxrod commented Jul 31, 2021 via email

@gedeck
Copy link
Owner

gedeck commented Jul 31, 2021

The command

print(np.mean(perm_diffs > mean_b - mean_a))

is correct. It probably warrants some explanation. perm_diffs is a vector of possible differences of means for A and B. mean_b - mean_a is a number, the actual difference between the means of A and B.

perm_diffs > mean_b - mean_a is a boolean vector of the same length of perm_diffs where we have True in the corresponding element of perm_diffs is greater than the actual difference of the means and False otherwise, e.g.

[True, True, False, ...., False, True]

Python and R (and a lot of other languages) interpret True as 1 and False as 0. Calculating the means of this vector gives me the percentage of True values. In the book this is 0.121. This is what we want to know.

print(np.mean(perm_diffs) > mean_b - mean_a)

on the other hand will print either True or False.

Thanks for spotting the typo in the filename. It is now corrected.

@pdxrod
Copy link
Author

pdxrod commented Jul 31, 2021 via email

@gedeck
Copy link
Owner

gedeck commented Jul 31, 2021

This issue was reported before #23 but never got the versions. The problem is that mean_a and mean_b are float and not numpy.float64. The means come from pandas, so it must be an inconsistency with that version. Can you send your pandas version?

@pdxrod
Copy link
Author

pdxrod commented Aug 1, 2021 via email

@gedeck
Copy link
Owner

gedeck commented Aug 1, 2021

My versions are: Python 3.9.4, numpy 1.20.2, and pandas 1.2.4

I looked at the various pandas release notes since 1.1.3 but couldn't pinpoint when it was fixed. There are several fixes related to regressions in type casting and it's likely that this was working before 1.1.3 and fixed again after.

I suggest you update pandas to a newer version.

@pdxrod
Copy link
Author

pdxrod commented Aug 2, 2021 via email

@gedeck
Copy link
Owner

gedeck commented Aug 2, 2021

The scipy version that I use is scipy==1.7.0.

I just downgraded my pandas and numpy version to yours and the code still works. It could be an OS related issue. I can run the code on MacOS and Linux, but don't have windows to try it.

@pdxrod
Copy link
Author

pdxrod commented Aug 2, 2021 via email

@gedeck
Copy link
Owner

gedeck commented Aug 2, 2021

Did you try:

print(np.mean(np.array(perm_diffs) > mean_b - mean_a))

@pdxrod
Copy link
Author

pdxrod commented Aug 3, 2021 via email

@pdxrod
Copy link
Author

pdxrod commented Aug 9, 2021 via email

@gedeck
Copy link
Owner

gedeck commented Aug 9, 2021

I would pick the first one to start with.
https://www.amazon.com/Hands-Machine-Learning-Scikit-Learn-TensorFlow/dp/1492032646/

There is also this book that is available online and in paper:
https://www.deeplearningbook.org/
https://mitpress.mit.edu/books/deep-learning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants