Home › Fóruns › Fórum Ciência de Dados para Empresas e Negócios › Pré processamento erros conforme abaixo mostrados
Marcado: Intuição+sobre+Regressão+Lógistica+Random+Forest+e+Redes+neurais+(Departamento+de+recursos+humanos)
- Este tópico contém 5 respostas, 4 vozes e foi atualizado pela última vez 11 meses, 3 semanas atrás por
Jones Granatyr.
- AutorPosts
- 26 de outubro de 2023 às 18:21 #42551
Na parte de pré-processamento do curso de Ciências de Dados para empresas e Negócios está acontecendo esses erros:
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
X = scaler.fit_transform(X_all)TypeError Traceback (most recent call last)
in ()
1 from sklearn.preprocessing import MinMaxScaler
2 scaler = MinMaxScaler()
—-> 3 X = scaler.fit_transform(X_all)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.
Mias embaixo:
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25)NameError Traceback (most recent call last)
in ()
1 from sklearn.model_selection import train_test_split
—-> 2 X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25)NameError: name ‘X’ is not defined
Abaixo:
X_train.shape, y_train
NameError Traceback (most recent call last)
in ()
—-> 1 X_train.shape, y_trainNameError: name ‘X_train’ is not defined
Abaixo:
X_test.shade, y_test
—————————————————————————
NameError Traceback (most recent call last)
in ()
—-> 1 X_test.shade, y_testNameError: name ‘X_test’ is not defined
Poderia ajudar?
30 de outubro de 2023 às 10:46 #42570Olá Jonathan, verifique se há algum erro de digitação no nome das variáveis.
Fabio
19 de novembro de 2023 às 19:54 #42882Tive o mesmo erro troque o nome da variáveis , coloquei X, x, Nada resolveu.
Reuniciei a maquina, o collab, tudo
A mensagem diz que tem dados em formato de string provavelmente no x_cat.
Reconverti tudo mas deu o mesmo erro
—————————————————————————
TypeError Traceback (most recent call last)
<ipython-input-75-3e293ed36e51> in <cell line: 3>()
1 from sklearn.preprocessing import MinMaxScaler
2 scaler = MinMaxScaler()
—-> 3 X = scaler.fit_transform(X_all)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.
19 de novembro de 2023 às 20:28 #42883print(X_all.dtypes)
a coluna overtime está como objeto
NumCompaniesWorked int64
OverTime object
PercentSalaryHike int64
PerformanceRating int64
19 de novembro de 2023 às 20:28 #42884Chatgpt
X_all.columns = X_all.columns.astype(str)
RESOLVIDO
3 de maio de 2024 às 11:27 #44643Que bom que deu certo!
- AutorPosts
- Você deve fazer login para responder a este tópico.