I am trying to build a machine learning model for my understanding .I am getting exception when running and trying to build model for training data. I see below exception during execution of programme.
**Exception Trace :
C:\python-workspace\venv\lib\site-packages\sklearn\utils\validation.py:976: FutureWarning: Arrays of bytes/strings is being converted to decimal numbers if dtype='numeric'. This behavior is deprecated in 0.24 and will be removed in 1.1 (renaming of 0.26). Please convert your data to numeric values explicitly instead.
estimator=estimator,
Traceback (most recent call last):
File "C:\python-workspace\venv\lib\site-packages\sklearn\utils\validation.py", line 787, in check_array
array = array.astype(np.float64)
ValueError: could not convert string to float: 'male'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\python-workspace\NTLRApp.py", line 113, in
lr.fit(X_train, y_train)
File "C:\python-workspace\venv\lib\site-packages\sklearn\linear_model_base.py", line 663, in fit
X, y, accept_sparse=accept_sparse, y_numeric=True, multi_output=True
File "C:\python-workspace\venv\lib\site-packages\sklearn\base.py", line 581, in _validate_data
X, y = check_X_y(X, y, *check_params)
File "C:\python-workspace\venv\lib\site-packages\sklearn\utils\validation.py", line 976, in check_X_y
estimator=estimator,
File "C:\python-workspace\venv\lib\site-packages\sklearn\utils\validation.py", line 792, in check_array
) from e
ValueError: Unable to convert array of bytes/strings into decimal numbers with dtype='numeric'
*
Could you please look at above trace and suggest me what wrong , i have done in the piece of code.
Error : ValueError: could not convert string to float: 'male'
Question/Query : I am not able to understand why programme is trying to convert object or string into float data type. What is the need to perform conversion here.
Hello Everyone ,
I am trying to build a machine learning model for my understanding .I am getting exception when running and trying to build model for training data. I see below exception during execution of programme.
**Exception Trace :
C:\python-workspace\venv\lib\site-packages\sklearn\utils\validation.py:976: FutureWarning: Arrays of bytes/strings is being converted to decimal numbers if dtype='numeric'. This behavior is deprecated in 0.24 and will be removed in 1.1 (renaming of 0.26). Please convert your data to numeric values explicitly instead.
estimator=estimator,
Traceback (most recent call last):
File "C:\python-workspace\venv\lib\site-packages\sklearn\utils\validation.py", line 787, in check_array
array = array.astype(np.float64)
ValueError: could not convert string to float: 'male'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\python-workspace\NTLRApp.py", line 113, in
lr.fit(X_train, y_train)
File "C:\python-workspace\venv\lib\site-packages\sklearn\linear_model_base.py", line 663, in fit
X, y, accept_sparse=accept_sparse, y_numeric=True, multi_output=True
File "C:\python-workspace\venv\lib\site-packages\sklearn\base.py", line 581, in _validate_data
X, y = check_X_y(X, y, *check_params)
File "C:\python-workspace\venv\lib\site-packages\sklearn\utils\validation.py", line 976, in check_X_y
estimator=estimator,
File "C:\python-workspace\venv\lib\site-packages\sklearn\utils\validation.py", line 792, in check_array
) from e
ValueError: Unable to convert array of bytes/strings into decimal numbers with dtype='numeric'
*
Could you please look at above trace and suggest me what wrong , i have done in the piece of code.
Try to Google/Stackoverflow the last line
Hi , I tried to understand and facing some doubts about error which getting during execution.
Below is my dtypes :
age int64
sex object
bmi float64
children int64
smoker object
region object
expenses float64
dtype: object
Index(['age', 'bmi', 'children', 'expenses', 'sex_female', 'sex_male',
'smoker_no', 'smoker_yes', 'region_northeast', 'region_northwest',
'region_southeast', 'region_southwest'],
dtype='object')
Error : ValueError: could not convert string to float: 'male'
Question/Query : I am not able to understand why programme is trying to convert object or string into float data type. What is the need to perform conversion here.
The odd that you find a specialist of your problem at hand here is very slim.
This kind of super focused question work better at stackoverflow.com/