Intel® oneAPI Data Analytics Library
Community support for building compute-intensive applications that run fast on Intel® architecture.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
204 Discussions

Unhandled exception in Kdtree KNN on in memory data

mchinmay
Beginner
625 Views

I am trying to use kdtree_knn_classification to do a 2d  k-nearest neighbour search on in-memory data. However i am getting an unhandled exception in the algorithm.compute() function.    Attached is my code snippet.  Is something wrong with my usage? Unfortunately i am not able to figure out from the documentation and the examples. Please help!  I am using daal 2021.1.1

 

mchinmay_1-1607949759486.png

 

 

0 Kudos
1 Solution
alexander_andreev
581 Views

Hi,

Instead of

algorithm.parameter.nClasses = 1;

use

algorithm.parameter.resultsToEvaluate = classifier::none;
algorithm.parameter.resultsToCompute = kdtree_knn_classification::computeDistances | kdtree_knn_classification::computeIndicesOfNeighbors;

and delete line

algorithm.input.set(classifier::training::labels, trainLabel);

to enable plain knn search without classification. Despite on your task, you might drop distances (kdtree_knn_classification::computeDistances) or indices (kdtree_knn_classification::computeIndicesOfNeighbors).

If classification is also needed, return label input line, delete line with resultsToEvaluate and add nClasses > 1:

algorithm.parameter.nClasses = nClasses;

Kind regards,

Alexander.

View solution in original post

5 Replies
RaeesaM_Intel
Moderator
597 Views

Hi,

Thank you for posting in Intel® oneAPI Data Analytics Library & Intel® Data Analytics Acceleration Library Forum.


Please share the operating system details.

Have you tried running the kdtree_knn_dense_batch sample of daal 2021.1.1 available with oneAPI base toolkit on linux . We were able to run it successfully without any issues, so the error you mentioned might be code related.

Here are the steps to build and run that sample using c++ compiler on linux:

1)     Setting up oneAPI environment via setvars.sh script:

source <install_directory>/setvars.sh

2)     DAAL kdtree sample is present in the below folder:

<install_directory>/dal/2021.1.1/examples/daal/cpp/source/k_nearest_neighbors/

3)     Use the makefile to build and run the DAAL examples, You can try any of the below commands:

cd <install_directory>/dal/2021.1.1/examples/daal/cpp/

4)     make libintel64 example=kdtree_knn_ dense_batch

[Now, it will build by Intel(R) oneAPI DPC++ Compiler (as default) and run pca example for 64-bit applications and do static linking]

OR

make sointel64 example= kdtree_knn_ dense_batch

[build by Intel(R) oneAPI Compiler (as default) and run all examples for Intel(R)64 processor family applications, dynamic linking


Please refer the following link for further details :

https://oneapi-src.github.io/oneDAL/getstarted.html#

https://software.intel.com/content/www/us/en/develop/documentation/get-started-intel-oneapi-data-ana...


Get back to us in case of any issues.

Thank you,

Raeesa


mchinmay
Beginner
547 Views

Hi,

Thanks for your reply.

I am using windows 10 enterprise and visual studio17 version 15.9.13.

Thanks

 

alexander_andreev
582 Views

Hi,

Instead of

algorithm.parameter.nClasses = 1;

use

algorithm.parameter.resultsToEvaluate = classifier::none;
algorithm.parameter.resultsToCompute = kdtree_knn_classification::computeDistances | kdtree_knn_classification::computeIndicesOfNeighbors;

and delete line

algorithm.input.set(classifier::training::labels, trainLabel);

to enable plain knn search without classification. Despite on your task, you might drop distances (kdtree_knn_classification::computeDistances) or indices (kdtree_knn_classification::computeIndicesOfNeighbors).

If classification is also needed, return label input line, delete line with resultsToEvaluate and add nClasses > 1:

algorithm.parameter.nClasses = nClasses;

Kind regards,

Alexander.

View solution in original post

mchinmay
Beginner
543 Views

Hi Alexander,

Thanks for your solution.  Setting algorithm.parameter.resultsToEvaluate = classifier::none worked for me.

 

RaeesaM_Intel
Moderator
525 Views

Hi,


Glad to know that your issue got resolved. We are discontinuing monitoring this thread.Please raise a new thread in case of any further issues.


Thanks,

Raeesa


Reply