How can I improve the performance of KNN model
I had created a KNN classification model, by comprising the basic classification model development function, but when i fetched the accuracy of the model using the mean squared error function I found that the accuracy of the model was a bit low. I need support to enhance the accuracy of the model demonstrated below:
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import mean_squared_error
from math import sqrt
# load data
df_bridge = pd.read_csv ("bridge_data.csv")
# categorize data
X = df_bridge.drop("8 - Structure Number", axis=1).drop("43A - Main Span Material", axis=1)
X = X.values
y = df_bridge["8 - Structure Number"]
y = y.values
# Split into training and test set
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state=42)
# Apply the Prediction KNN model
knn = KNeighborsClassifier(n_neighbors=7)
knn.fit(X_train, y_train)
knn_train_preds = knn.predict(X_train)
mse = mean_squared_error(y_train, knn_train_preds)
rmse = sqrt(mse)
rmse