<jupyter_start><jupyter_text><jupyter_code>from sklearn.datasets import load_iris
iris=load_iris()

print(iris)


print(iris.feature_names)
print(iris.target_names)<jupyter_output>['setosa' 'versicolor' 'virginica']<jupyter_text><jupyter_code>print(iris.data.shape)
from sklearn import datasets
X, y=datasets.load_iris(return_X_y=True)
from sklearn.model_selection import train_test_split
X_train,X_test ,y_train,y_test=train_test_split(X,y,test_size=0.2,random_state=4)
from sklearn.neighbors import KNeighborsClassifier
from sklearn import metrics




k_range=range(1,26)
scores={}
scores_list=[]
for k in k_range:
  model=KNeighborsClassifier(n_neighbors=k)
  model.fit(X_train, y_train)
  y_pred=model.predict(X_test)
  scores[k]=metrics.accuracy_score(y_test,y_pred)
  print(scores)
  scores_list.append(metrics.accuracy_score(y_test,y_pred))
import matplotlib.pyplot as plt
plt.plot(k_range,scores_list)
plt.xlabel('K-value')
plt.ylabel('Testing accuracy')
model=KNeighborsClassifier(n_neighbors=5)
model.fit(X,y)
accuracy=model.score(X_test,y_test)
print('accuracy %.2f%% on text data '%(accuracy*100))
from sklearn.metrics import classification_report
predictions=model.predict(X_test)
print("Classification report")
print(classification_report(y_test,predictions))
from sklearn.metrics import confusion_matrix
print("Confusion matrix")
print(confusion_matrix(y_test,predictions))
print("Accuracy")<jupyter_output>Confusion matrix
[[16  0  0]
 [ 0  4  1]
 [ 0  0  9]]
Accuracy
{'fraction_non_alphanumeric': 0.11725067385444744, 'fraction_numerical': 0.014150943396226415, 'mean_word_length': 9.45774647887324, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '621614', 'license': 'BSD-2-Clause-FreeBSD', 'n_tokens_mistral': 596, 'n_tokens_neox': 568, 'n_words': 88, 'path': 'supervised.ipynb', 'repo_name': 'deepbora/cry-decryptor', 'size': '1484'}