Hi, I am getting this error when running Code Block 1Z.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-140-20fc8ed86092> in <cell line: 2>()
1 # Fitting the model to the training data (X_train) and corresponding labels (y_train)
----> 2 model.fit(X_train, y_train)
6 frames
/usr/local/lib/python3.10/dist-packages/pandas/core/generic.py in __array__(self, dtype, copy)
2151 ) -> np.ndarray:
2152 values = self._values
-> 2153 arr = np.asarray(values, dtype=dtype)
2154 if (
2155 astype_is_view(values.dtype, arr.dtype)
ValueError: could not convert string to float: 'Multi-Focal'
Moderator note: https://www.sciencebuddies.org/science- ... oid_cancer
Thyroid Cancer Recurrence
Moderators: kgudger, bfinio, Moderators
-
codeninja405
- Posts: 4
- Joined: Sun Nov 03, 2024 11:43 am
- Occupation: Student
-
amyCC
- Site Admin
- Posts: 398
- Joined: Wed Apr 01, 2020 4:02 pm
- Occupation: Moderator
- Project Question: *
- Project Due Date: *
- Project Status: Not applicable
Re: Thyroid Cancer Recurrence
Please double-check to ensure you have completed all TODO steps in the previous blocks and run those blocks without error.
If you stopped and came back, rebooted, etc., make sure that all cells have been run by going to the block you are at and using Runtime / Run Before to make sure all previous blocks are re-run (and that all of the code changes you made have held). Make sure there are no errors in ANY of the previous blocks. Then run 1Z again.
If you are still having trouble, can you show a screenshot of the output you see for 1V.
I am curious where you may have used Multi-Focal in your file, too. If you do a search on that in your notebook, where does it come up? (The TODO blocks all give you specific names to use for the processing of the data.)
Amy
Science Buddies
If you stopped and came back, rebooted, etc., make sure that all cells have been run by going to the block you are at and using Runtime / Run Before to make sure all previous blocks are re-run (and that all of the code changes you made have held). Make sure there are no errors in ANY of the previous blocks. Then run 1Z again.
If you are still having trouble, can you show a screenshot of the output you see for 1V.
I am curious where you may have used Multi-Focal in your file, too. If you do a search on that in your notebook, where does it come up? (The TODO blocks all give you specific names to use for the processing of the data.)
Amy
Science Buddies
-
codeninja405
- Posts: 4
- Joined: Sun Nov 03, 2024 11:43 am
- Occupation: Student
Re: Thyroid Cancer Recurrence
Hi! Yes, I have completed every code block and there were no errors. I reran everything but Code Block 1Z still isn't working. I have attached a screenshot so you can see it. Also, I haven't used multifocal in the code, except when it was in the data. Thank you!
- Attachments
-
- Code Block 1Z.PNG (36.34 KiB) Viewed 12682 times
-
amyCC
- Site Admin
- Posts: 398
- Joined: Wed Apr 01, 2020 4:02 pm
- Occupation: Moderator
- Project Question: *
- Project Due Date: *
- Project Status: Not applicable
Re: Thyroid Cancer Recurrence
Can you please show a screenshot of the output you see for 1V. If you have completed all to-do blocks successfully, the data will all be numerical. (The word "Multi-Focal" won't appear in the data, and the error you are seeing suggests it may be.)
Can you please also show a screenshot of the output you have for 1D -- and the code you entered for the TO-DO. (That is the block where you convert the column with Multi-Focal into numbers....
Amy
Science Buddies
Can you please also show a screenshot of the output you have for 1D -- and the code you entered for the TO-DO. (That is the block where you convert the column with Multi-Focal into numbers....
Amy
Science Buddies
-
codeninja405
- Posts: 4
- Joined: Sun Nov 03, 2024 11:43 am
- Occupation: Student
Re: Thyroid Cancer Recurrence
Hi! Here is the output I see for 1Z and 1D. I have attached the screenshots below.
- Attachments
-
- Science Project 2.PNG (39.94 KiB) Viewed 12659 times
-
- Science Proposal.PNG (41.11 KiB) Viewed 12659 times
-
amyCC
- Site Admin
- Posts: 398
- Joined: Wed Apr 01, 2020 4:02 pm
- Occupation: Moderator
- Project Question: *
- Project Due Date: *
- Project Status: Not applicable
Re: Thyroid Cancer Recurrence
The syntax is wrong in 1D. You shouldn't have "and" in there.
When you look at the output you had for 1V, see how the "words" still appear in the Focality column? They shouldn't.
As noted above, all the steps you were taking were to convert all the data to numbers.
Look again at the directions for the 1D TO-DO (the syntax of it).
Like other blocks you edited, it will use this form: ['value', 'value', 'value']
Amy
Science Buddies
When you look at the output you had for 1V, see how the "words" still appear in the Focality column? They shouldn't.
As noted above, all the steps you were taking were to convert all the data to numbers.
Look again at the directions for the 1D TO-DO (the syntax of it).
Like other blocks you edited, it will use this form: ['value', 'value', 'value']
Amy
Science Buddies
-
codeninja405
- Posts: 4
- Joined: Sun Nov 03, 2024 11:43 am
- Occupation: Student
Re: Thyroid Cancer Recurrence
It worked! Thank you so much!
-
amyCC
- Site Admin
- Posts: 398
- Joined: Wed Apr 01, 2020 4:02 pm
- Occupation: Moderator
- Project Question: *
- Project Due Date: *
- Project Status: Not applicable
Re: Thyroid Cancer Recurrence
That's great! I'm glad you got that sorted out.
Amy
Science Buddies
Amy
Science Buddies

