-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Model.fit value error #17118
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
Comments
X = music.drop(columns=['genre']) What kind of values do you have for this variable? |
numerical value not string...x represent a table consists of two columns and 20 rows. contained numerical values. |
Make Sure to clean the dataset first. Remove or replace all the missing values. Make sure that all the values in the column is of same data type. |
Hey @ramapati166! I will close this issue since it has not been updated in a long time and we are not able to reproduce it. Feel free to re-open it if you disagree. |
It's ok.No problem..
…On Tue, Aug 25, 2020, 9:09 PM Juan Carlos Alfaro Jiménez < ***@***.***> wrote:
Closed #17118 <#17118>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#17118 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOZV3PHWYMXBQNUINEUL65LSCPLKZANCNFSM4MYPRH2A>
.
|
Any idea what could be causing this error? I've been trying to solve this for a week. Thanks in advance
main program is:
import pandas as pd
from sklearn.tree import DecisionTreeClassifier
music = pd.read_csv('sun1.csv')
X = music.drop(columns=['genre'])
y= music['genre']
model = DecisionTreeClassifier()
model.fit(X, y)
predictions=model.predict([ [21,1], [22, 0] ])
predictions
ValueError Traceback (most recent call last)
in
6
7 model = DecisionTreeClassifier()
----> 8 model.fit(X, y)
9 time.sleep(0.1)
10 predictions=model.predict([ [21,1], [22, 0] ])
C:\ProgramData\Anaconda3\lib\site-packages\sklearn\tree_classes.py in fit(self, X, y, sample_weight, check_input, X_idx_sorted)
875 sample_weight=sample_weight,
876 check_input=check_input,
--> 877 X_idx_sorted=X_idx_sorted)
878 return self
879
C:\ProgramData\Anaconda3\lib\site-packages\sklearn\tree_classes.py in fit(self, X, y, sample_weight, check_input, X_idx_sorted)
147
148 if check_input:
--> 149 X = check_array(X, dtype=DTYPE, accept_sparse="csc")
150 y = check_array(y, ensure_2d=False, dtype=None)
151 if issparse(X):
C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
576 if force_all_finite:
577 _assert_all_finite(array,
--> 578 allow_nan=force_all_finite == 'allow-nan')
579
580 if ensure_min_samples > 0:
C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\validation.py in _assert_all_finite(X, allow_nan, msg_dtype)
58 msg_err.format
59 (type_err,
---> 60 msg_dtype if msg_dtype is not None else X.dtype)
61 )
62 # for object dtype data, we only check for NaNs (GH-13254)
ValueError: Input contains NaN, infinity or a value too large for dtype('float32').
The text was updated successfully, but these errors were encountered: