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

Page 19 Error #45

Open
NakulGoswami opened this issue Jun 17, 2021 · 3 comments
Open

Page 19 Error #45

NakulGoswami opened this issue Jun 17, 2021 · 3 comments

Comments

@NakulGoswami
Copy link

Hi Abhishek,
I recently bought your book.
I get the following error when I ren the code that is ritten on page 19.

clf.fit(df_train[cols], df_train.quality)
AttributeError: 'list' object has no attribute 'fit'

Can you help with the accurate code?
Thanks
Nakul

@NakulGoswami
Copy link
Author

Hi Abhishek,
In addition,
when I try to run the first code in the book, I get the following error.
I am sure it is somenthing simple, but do please let me know how to proceed?
Is there an updated code list for your book that you can point me to because that would be helpful.

Thanks
Nakul

TypeError Traceback (most recent call last)
TypeError: '(1, slice(None, None, None))' is an invalid key

in
15 pixel_values, targets = data
16 targets = targets.astype(int)
---> 17 single_image = pixel_values[1, :].reshape(28, 28)
18 plt.imshow(single_image, cmap='gray')
19 tsne = manifold.TSNE(n_components=2, random_state=42)
~\Anaconda3\lib\site-packages\pandas\core\frame.py in getitem(self, key)
3022 if self.columns.nlevels > 1:
3023 return self._getitem_multilevel(key)
-> 3024 indexer = self.columns.get_loc(key)
3025 if is_integer(indexer):
3026 indexer = [indexer]
~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
3078 casted_key = self._maybe_cast_indexer(key)
3079 try:
-> 3080 return self._engine.get_loc(casted_key)
3081 except KeyError as err:
3082 raise KeyError(key) from err
pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

@kaliappan01
Copy link

kaliappan01 commented Jun 18, 2021

Hi Abhishek,
I recently bought your book.
I get the following error when I ren the code that is ritten on page 19.

clf.fit(df_train[cols], df_train.quality)
AttributeError: 'list' object has no attribute 'fit'

Can you help with the accurate code?
Thanks
Nakul

Hello Nakul , I fear you have not initialized the model variable clf correctly .
Can u post a pic or snippet of your code ?

@syriacus99
Copy link

syriacus99 commented Aug 9, 2023

Hi Abhishek, In addition, when I try to run the first code in the book, I get the following error. I am sure it is somenthing simple, but do please let me know how to proceed? Is there an updated code list for your book that you can point me to because that would be helpful.

Thanks Nakul

TypeError Traceback (most recent call last) TypeError: '(1, slice(None, None, None))' is an invalid key

in 15 pixel_values, targets = data 16 targets = targets.astype(int) ---> 17 single_image = pixel_values[1, :].reshape(28, 28) 18 plt.imshow(single_image, cmap='gray') 19 tsne = manifold.TSNE(n_components=2, random_state=42) ~\Anaconda3\lib\site-packages\pandas\core\frame.py in getitem(self, key) 3022 if self.columns.nlevels > 1: 3023 return self._getitem_multilevel(key) -> 3024 indexer = self.columns.get_loc(key) 3025 if is_integer(indexer): 3026 indexer = [indexer] ~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 3078 casted_key = self._maybe_cast_indexer(key) 3079 try: -> 3080 return self._engine.get_loc(casted_key) 3081 except KeyError as err: 3082 raise KeyError(key) from err pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

TypeError Traceback (most recent call last)
TypeError: '(1, slice(None, None, None))' is an invalid key
To solve this problem, you should to change code to "single_image = pixel_values[1, :].reshape(28, 28)" .It works

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

3 participants