lundi 10 mai 2021

K-nearest neighbor model with gaussian distribution

Assume that I have 3 different classes which follow a Gaussian distribution generated in the following way :

x1 = np.random.random((100,7))
x2 = np.random.random((200,7))
x3 = np.random.random((300,7))

mean_x1 = np.mean(x1, axis = 0)
mean_x2 = np.mean(x2, axis = 0)
mean_x3 = np.mean(x3, axis = 0)

cov_x1 = np.cov(x1.T)
cov_x2 = np.cov(x2.T)
cov_x3 = np.cov(x3.T)

Class_1 = np.random.multivariate_normal(mean_x1, cov_x1, 100)
Class_2 = np.random.multivariate_normal(mean_x2, cov_x2, 200)
Class_3 = np.random.multivariate_normal(mean_x3, cov_x3, 300)

And that I would like to perform a classification task based on KNN model to predict the Class of a test sample which also follows a Gaussian distribution,i.e., if it is Class_1, Class_2 or Class_3 based on their mean values.

Can someone provide me with an explanation how could i do it please ?




Aucun commentaire:

Enregistrer un commentaire