简体   繁体   English

ValueError:输入包含 NaN、无穷大或对于 dtype('float64') 来说太大的值。 在安装时 model

[英]ValueError: Input contains NaN, infinity or a value too large for dtype('float64'). While fitting in model

import pandas as pd
df=pd.read_csv('titanic.csv')
from sklearn.linear_model import LogisticRegression
df['male']=df['Sex']=='male'
X= df[['Pclass','male','Age','SibSp','Parch','Fare']].values
y= df['Survived'].values
model=LogisticRegression()
model.fit(X,y)

ValueError: Input contains NaN, infinity or a value too large for dtype('float64'). ValueError:输入包含 NaN、无穷大或对于 dtype('float64') 来说太大的值。

Please Help me to remove this error请帮我删除这个错误

Don't know if it's the same, but in my case that error was due to big numbers, in particular I found those with scientific notation, such as 3.63E+08, 1.25E+09... The solution is to replace those numbers with something smaller: you can either simply replace them with x / 1000 or, the best solution, use a function to scale or normalise the data.不知道是不是一样,但在我的情况下,错误是由于数字大,特别是我发现那些有科学计数法的,比如3.63E+08、1.25E+09……解决办法是替换那些较小的数字:您可以简单地用 x / 1000 替换它们,或者最好的解决方案是使用 function 来缩放或规范化数据。 After that, you can train your model之后,您可以训练您的 model

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ValueError: Input contains NaN, infinity or a value too large for dtype('float64') While fit the model after Imputation - ValueError: Input contains NaN, infinity or a value too large for dtype('float64') While fitting the model After Imputation ValueError:输入包含 NaN、无穷大或对于 dtype('float64') 来说太大的值。 拟合误差机器学习 - ValueError: Input contains NaN, infinity or a value too large for dtype('float64'). FITTING ERROR MACHINE LERNING ValueError: 输入包含 NaN、无穷大或对于 dtype('float64') 来说太大的值。 对于我的 knn 模型 - ValueError: Input contains NaN, infinity or a value too large for dtype('float64'). for my knn model ValueError:在预处理数据时,输入包含NaN,无穷大或对于dtype('float64')而言太大的值 - ValueError: Input contains NaN, infinity or a value too large for dtype('float64') while preprocessing Data StandardScaler -ValueError:输入包含NaN,无穷大或对于dtype('float64')而言太大的值 - StandardScaler -ValueError: Input contains NaN, infinity or a value too large for dtype('float64') ValueError:输入包含 NaN、无穷大或对于 scikit-learn 的 dtype('float64') 来说太大的值 - ValueError: Input contains NaN, infinity or a value too large for dtype('float64') with scikit-learn ValueError:使用 sklearn IterativeImputer 时,输入包含 NaN、无穷大或对于 dtype('float64') 来说太大的值 - ValueError: Input contains NaN, infinity or a value too large for dtype('float64'), when using sklearn IterativeImputer ValueError:输入包含 NaN、无穷大或对于线性回归中的 dtype('float64') 而言太大的值 - ValueError: Input contains NaN, infinity or a value too large for dtype('float64') in linear regression KNN ValueError:输入包含NaN,无穷大或对于dtype('float64')而言太大的值 - KNN ValueError: Input contains NaN, infinity or a value too large for dtype('float64') 如何解决ValueError:输入包含NaN,无穷大或对于dtype来说太大的值('float64') - How to resolve ValueError: Input contains NaN, infinity or a value too large for dtype('float64')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM