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')
我该如何解决?
答案 0 :(得分:0)
确保您没有NaN
值:
df1 = df1.dropna()