1
$\begingroup$

I have used

nbrs = NearestNeighbors(metric= 'cosine', algorithm='brute').fit(items_features)

distances, indices = nbrs.kneighbors(item_features)

to find some suggested items based on some attributes in the dataset. I really find the suggested items but I need to see if these items are really the more nearest items.

I tried this function to find the similarity between distances of A with each items B or C or D spatial.distance.cosine(distances of A,distances of B/C/D)

One output for my code is

B with 0.0004864387565900463
C with 0.003675794744087746
D with 0.05855020953442236
E with 0.0048087457894999686

I thought the items must be orderd from the neighrest but E is break the rule. Is those distances in above is logic or there is a wrong.

How can I make sure my algorithm work well???

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.