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

Chapter 4 typo - page 132 #98

Open
polishtits opened this issue Jan 26, 2019 · 3 comments
Open

Chapter 4 typo - page 132 #98

polishtits opened this issue Jan 26, 2019 · 3 comments
Labels

Comments

@polishtits
Copy link

polishtits commented Jan 26, 2019

Greetings professor Raschka,
Thank you for writing such an amazing book!
On Page 132, I found a small bug in SBS class:
Original:
def transform(self, X): return X[:, self.indices_]

I think the correct code should be:
def transform(self, X): return X[:, self.subsets_[np.argmax(self.scores_)]

@weishanlee
Copy link

The two results seem the same. Do you get different results?

@polishtits
Copy link
Author

@weishanlee I tried the original code with my project, and always ended up with transform method always transformed the original array into a one column array. The reason is that after fit method has been called, self.indices_ is the score of the last permutation, and what we actually want is the best score across permutations, not the last permutation itself.

@rasbt
Copy link
Owner

rasbt commented Jun 14, 2019

Thanks for the note, and sorry for the late response. I somehow missed the notification.

I am not quite sure if I am following the in the code, we have

               best = np.argmax(scores)
               self.indices_ = subsets[best]

So the transform method should yield the best subset of size k. If you do

def transform(self, X): 
    return X[:, self.subsets_[np.argmax(self.scores_)]

it would return the best subset regardless of the size (so it won't necessarily be size k) when I see that correctly

@rasbt rasbt added the question label Jun 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants