![](/img/trans.png)
[英]KNN ValueError: Input contains NaN, infinity or a value too large for dtype('float64')
[英]ValueError: Input contains NaN, infinity or a value too large for dtype('float64'). for my knn model
df1_fit=pd.DataFrame(scaled_features,columns=df1.columns[:-1])
df1_fit.head()
from sklearn.model_selection import train_test_split
X_train, X_test, y_train,
y_test=train_test_split(scaled_features,df1['Sales'],test_size=0.30)
from sklearn.neighbors import KNeighborsClassifier
knn=KNeighborsClassifier(n_neighbors=5)
knn.fit(X_train,y_train)
然后我運行它,但它顯示我, ValueError: Input contains NaN, infinity or a value too large for dtype('float64')
我該如何解決?
確保您沒有NaN
值:
df1 = df1.dropna()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.