# Classification method when idea conditions are known?

Dataset: Concrete measured on 8 sets of properties. ~4000 data points.

Known: under ideal condition, value of 8 properties for 10 different types of concrete.

The objective is to find: in 8 dimension space, what is the 'type of concrete' to which the given data point is nearest to.

I think image well explains the question if my words are confusing. Black = idea condition. Red = points who's category need to be identified.

Clarification:

from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier(n_neighbors=8)
knn.fit(X_train, y_train)
pred = knn.predict(X_test)


If i understand correctly, it would be acceptable to: X_train will be array of 8 by 10 and Y_train will be array of 1 by 10. Is this correct.

• if your reds points need to be classified as the same categorie of the nearest black point, go check k nearest neighborhood algorithm. – Jérémy Blain Oct 26 '18 at 9:58
• I did actually read about KNN before hand. Maybe its my lack of proper understanding, but most references suggest 'training data' to define those points (and subsequently decision boundary). Is it acceptable to start with predefined centers? – Martan Oct 26 '18 at 10:23
• I really don't know, I am not used to kNN, but I think we do that because you first don't have already classified data. Maybe comment the answer by Kasra to ask this question and make the answer more clear. – Jérémy Blain Oct 26 '18 at 10:26

Welcome to the community Martan!

If I understood your question well, you have a set of patterns (you call them idea condition) and a set of query points (samples) and you want to determine (predict) their labels according to their affinity/similarity/closeness to the pattern.

If it's right, then K-Nearest Neighbor algorithm is what you are looking for. Please note that in high dimensions Euclidean distance is distorted however 8 dimensions is fine.

Hope it helps and in case I did not understand well, please comment here so I can update my answer. Good Luck!

## Update

What you mentioned in your comment about training in KNN is right. Let me clarify the thing.

1. Classification as A Supervised Learning Process: This means that you already had some data and their classes. So you can partition your space according to all those labels. Image below shows partition of different classes (i am not the best painter specially in MS paint :D). Having this, a new point falls into one of these partitions so you can determine its label. Building such a partitioning is done in the training process as you said.

1. Nearest Neighbor Search: But isn't this method pretty natural? You really do not need to know Machine Learning to perform such an algorithm and indeed you use KNN in daily life (today you see your friend with some of his colleagues and a new person you dont know and you instantly think he is probably a colleague. The other day you see your friend with his family and a guy you dont know and you guess he is most probably a relative. That is conceptually KNN!). In your example you dont need to learn how to partition the space as you already have your predefined labels with fixed position (we do training to find this out. you already have it, so just go on!). Now you can just make a nearest neighbor search and say to which class a point belongs.