text_plain_output_1.png
from sklearn.ensemble import RandomForestClassifier

from sklearn.linear_model import LogisticRegression

from sklearn.model_selection import train_test_split

from sklearn.neighbors import KNeighborsClassifier

from sklearn.preprocessing import StandardScaler

import matplotlib.pyplot as plt

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

df = pd.read_csv('/kaggle/input/mba-admission/Admission.csv')

ndf = df.copy()
ndf['Decision'] = ndf['Decision'].astype('category')
ndf['Decision'] = ndf['Decision'].cat.codes

X = ndf.drop('Decision', axis=1)
y = ndf['Decision']

from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X = scaler.fit_transform(X)

from sklearn.neighbors import KNeighborsClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
rfr = RandomForestClassifier()
knn = KNeighborsClassifier()
logmod = LogisticRegression()
rfr.fit(X_train, y_train)
knn.fit(X_train, y_train)
logmod.fit(X_train, y_train)

error = []
for k in range(1, 40):
    knn = KNeighborsClassifier(n_neighbors=k)
    knn.fit(X_train, y_train)
    p = knn.predict(X_test)
    error.append(np.mean(y_test != p))

score = []
for i in range(1, 50):
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)
    knn = KNeighborsClassifier(n_neighbors=3)
    knn.fit(X_train, y_train)
    score.append(knn.score(X_test, y_test))
np.array(score).mean()