Home › Fóruns › Fórum Python para Finanças: Análise de Dados e Machine Learning › Erro no codigo de normalização
- Este tópico contém 1 resposta, 2 vozes e foi atualizado pela última vez 3 semanas, 3 dias atrás por
Denny Ceccon.
- AutorPosts
- 9 de maio de 2023 às 10:56 #40449
Edson Gomes Braz
Participantefrom sklearn.preprocessing import MinMaxScaler scaler = MinMaxScaler() dataset_normalizado = scaler.fit_transform(dataset)
TypeError Traceback (most recent call last)
<ipython-input-67-1b22fcc9588d> in <cell line: 3>()
1 from sklearn.preprocessing import MinMaxScaler
2 scaler = MinMaxScaler()
—-> 3 dataset_normalizado = scaler.fit_transform(dataset)6 frames
/usr/local/lib/python3.10/dist-packages/sklearn/utils/validation.py in _get_feature_names(X)
1901 # mixed type of string and non-string is not supported
1902 if len(types) > 1 and “str” in types:
-> 1903 raise TypeError(
1904 “Feature names are only supported if all input features have string names, ”
1905 f”but your input has {types} as feature name / column name types. ”TypeError: Feature names are only supported if all input features have string names, but your input has [‘int’, ‘str’] as feature name / column name types. If you want feature names to be stored and validated, you must convert them all to strings, by using X.columns = X.columns.astype(str) for example. Otherwise you can remove feature / column names from your input data, or convert them all to a non-string data type.
<div id=”acfifjfajpekbmhmjppnmmjgmhjkildl” class=”acfifjfajpekbmhmjppnmmjgmhjkildl”></div>
<div id=”acfifjfajpekbmhmjppnmmjgmhjkildl” class=”acfifjfajpekbmhmjppnmmjgmhjkildl”></div>15 de maio de 2023 às 10:42 #40477Denny Ceccon
ModeradorOlá Edson,
Pode seguir a recomendação que a própria mensagem de erro retorna:
X.columns = X.columns.astype(str)
(no seu caso,
X
édataset
) - AutorPosts
- Você deve fazer login para responder a este tópico.