0
I am trying to run a classification model and I am getting the feedback that it is not possible to convert string to float in the predictive variables. When I give a dtypes I see that all variables are float or Int. I did the whole exploratory analysis process, pre-processing: all variables are numerical, I scaled, I did variable selection with logistic regression and recursive elimination. Follows code:
from sklearn import tree
x_treino = ['a', 'b', 'c', 'd', 'e']
y_treino = ['tt']
x_teste = ['a', 'b', 'c', 'd', 'e']
# Criando o objeto logistic regression
model = LogisticRegression()
# Criando o objeto tree para classificação
model = tree.DecisionTreeClassifier()
# Treinando o modelo com dados de treino e checando o score
model.fit(x_treino, y_treino)
model.score(x_treino, y_treino)
# Previsões
valores_previstos = model.predict(x_teste)
You can help me how to solve this. Is there any way to look line by line at these variables to see if there are any characters in them?? Thanks
Hello guys. I couldn’t solve this problem, so I chose to do it another way using sklearn’s train_test_split package. I created manually the division of test and training data. Done this I ran the Machine Learning models smoothly.
– Edi
Good afternoon, Edi. I believe you meant "model.score(x_test, y_test)" instead of "model.score(x_workout, y_workout)" in your code, correct?
– Anderson Chaves