text_html_output_1.png
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis

from sklearn.neighbors import KNeighborsClassifier

import pandas as pd

glass = pd.read_csv('/kaggle/input/glass/glass.csv')

X = glass.copy().drop(['Type'], axis=1)
y = glass['Type'].copy()

from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
lda_model = LinearDiscriminantAnalysis(n_components=2)
lda_model.fit(X, y)
reduced_X = lda_model.transform(X).T

knnmodel = KNeighborsClassifier(n_neighbors=3)
knnmodel.fit(reduced_X.T, y)