import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import confusion_matrix, accuracy_score
# Load the dataset
dataset = pd.read_csv('/content/diabetes.csv')
# Define features and target
X = dataset.iloc[:, [0, 6]].values
y = dataset.iloc[:, 8].values
# Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=0)
# Scale the features
sc = MinMaxScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)
# Train the KNN classifier
classifier = KNeighborsClassifier(n_neighbors=5)
classifier.fit(X_train, y_train)
# Make predictions
y_pred = classifier.predict(X_test)
# Evaluate the model
cm = confusion_matrix(y_test, y_pred)
accuracy = accuracy_score(y_test, y_pred)
# Print results
print("Predicted labels:", y_pred)
print("Actual labels:", y_test)
print("Confusion matrix:\n", cm)
print("Accuracy:", accuracy)