I am having problem in this elbow method.
error_rate = []
for i in range(1,40):
knn = KNeighborsClassifier(n_neighbors=i)
knn.fit(X_train,y_train)
pred_i = knn.predict(X_test)
error_rate.append(np.mean(pred_i != y_test))
The last line of code is causing problem:
ValueError: Unable to coerce to Series, length must be 1: given 300