我尝试对我的数据进行逻辑回归,但出现此错误 ValueError:无法将字符串转换为 float :'28,37' 我的代码:
X_train, X_test, y_train, y_test = train_test_split(X, y,
stratify=y,
test_size=0.3)
logisticRegr = LogisticRegression()
logisticRegr.fit(X_train, y_train)
predictions = logisticRegr.predict(X_test)
请问我该如何解决?
最佳答案
字符串中的分隔符错误。您应该使用 .
而不是 ,
.
比较:
print(float('28,37'))
ValueError: could not convert string to float: '28,37'
致:
print(float('28.37'))
28.37
关于python - 错误:::ValueError: 无法将字符串转换为 float : '28,37',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56076692/