<jupyter_start><jupyter_text>KNN<jupyter_code>from sklearn.neighbors import KNeighborsClassifier
knn= KNeighborsClassifier(n_neighbors=1)
knn.fit(X_train, y_train)
pred= knn.predict(X_test)
pred
from sklearn.metrics import classification_report, confusion_matrix
print(confusion_matrix(y_test, pred))
print(classification_report(y_test, pred))
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))
    

plt.figure(figsize=(10,6))
plt.plot(range(1,40),error_rate,linestyle='dashed', marker='o', markerfacecolor= 'red', markersize=10)
##x me error_rate
##y me K
##error_Rate decrease ho rhi h 
error_rate<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12355212355212356, 'fraction_numerical': 0.015444015444015444, 'mean_word_length': 7.549450549450549, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '46898', 'license': 'MIT', 'n_tokens_mistral': 321, 'n_tokens_neox': 305, 'n_words': 51, 'path': 'classified notebook knn.ipynb', 'repo_name': 'didwania19csuf/K-NN', 'size': '777'}