Intel® oneAPI Data Analytics Library
Learn from community members on how to build compute-intensive applications that run efficiently on Intel® architecture.
225 Discussions

How to run the example code in onedal in oneapi (k-means).

GTC
Beginner
494 Views

You can show the steps to execute k-means in the onedal sample code, and how to build the project.

 

I had a lot of problems executing the sample code.

 

Don't know how to build projects.

GTC_0-1712826598212.png

 

How to write the corresponding cmake code. Can you show the corresponding example?

0 Kudos
1 Solution
Gennady_F_Intel
Moderator
310 Views

here are an outputs I see while building against the current version of oneDAL ( 2024.2) :

echo $DALROOT 

/opt/intel/oneapi/dal/2024.2/


Compiling:

icpx -std=c++11 -I"/opt/intel/oneapi/dal/2024.2/include" kmeans_csr_batch.cpp \

/opt/intel/oneapi/dal/2024.2/lib/libonedal_core.a /opt/intel/oneapi/dal/2024.2/lib/libonedal_thread.a -ltbb -ltbbmalloc -lpthread -ldl


================= Outputs:

./a.out

First 10 cluster assignments:

6.000   

13.000   

10.000   

13.000   

2.000   

10.000   

14.000   

12.000   

0.000   

16.000   


First 10 dimensions of centroids:

0.000   17.591  221.550  247.660  0.000   0.000   0.000   251.242  198.940  275.132  

295.622  0.000   301.130  0.000   0.000   241.016  227.610  240.671  13.663  232.512  

0.000   176.864  8.716   81.896  267.711  0.000   119.484  194.743  254.148  277.185  

296.199  1.397   298.152  0.000   0.000   250.834  220.490  242.556  10.894  229.351  

50.570  0.000   3.184   0.000   0.000   0.000   109.437  251.547  158.588  156.905  

214.201  269.138  36.219  0.000   0.000   0.000   271.184  96.983  290.968  291.172  

239.117  9.445   263.682  252.275  63.190  158.667  134.671  0.262   282.645  272.034  

0.000   22.133  226.067  247.111  0.000   0.000   0.000   247.122  186.600  272.500  

0.000   250.866  2.537   265.390  0.000   70.780  228.524  60.793  56.049  0.000   

256.038  61.826  198.376  3.691   102.215  133.238  0.000   0.000   14.235  252.678  

192.914  218.764  221.193  284.716  263.708  217.655  267.497  0.000   255.373  296.678  

103.797  273.434  5.323   151.360  103.414  0.000   216.677  256.367  0.000   172.625  

237.199  263.852  2.651   52.791  0.000   252.533  0.000   89.185  0.000   111.401  

211.218  68.119  270.124  218.696  250.426  134.625  49.897  107.415  221.530  87.616   

219.977  34.038  5.532   298.008  0.000   0.000   283.653  269.853  16.502  21.992   

238.584  262.239  238.637  185.528  261.533  5.855   281.647  0.546   75.414  224.607  

0.902   230.499  0.000   236.451  1.152   231.416  248.324  202.881  193.681  10.150   

0.000   52.300  4.777   297.508  0.000   0.000   279.362  275.869  4.831   21.431   

1.266   153.261  253.445  274.302  286.631  8.402   0.513   0.000   1.435   0.000   

198.149  255.631  228.151  288.604  270.971  275.645  0.000   102.600  182.940  123.002  


Objective function value:

341785984.000




View solution in original post

0 Kudos
3 Replies
Gennady_F_Intel
Moderator
319 Views

You could look at the oneDAL Getting Started Guide follow the link:

https://www.intel.com/content/www/us/en/docs/onedal/get-started-guide/2024-0/overview.html


please check there how to Build and run the examples from oneDAL as an example


# Navigate to the directory containing examples and then build them:

cd /examples/oneapi/dpc

make so example=svm_two_class_thunder_dense_batch # This will compile and run Correlation example using Intel(R) oneAPI DPC++/C++ Compiler

make so mode=build # This compiles all examples in the current directory



0 Kudos
Gennady_F_Intel
Moderator
317 Views

or you could look at the build applications with oneDAL follow another oneDAL Developer Reference & Guide:

https://www.intel.com/content/www/us/en/docs/onedal/developer-guide-reference/2024-1/build-application.html





0 Kudos
Gennady_F_Intel
Moderator
311 Views

here are an outputs I see while building against the current version of oneDAL ( 2024.2) :

echo $DALROOT 

/opt/intel/oneapi/dal/2024.2/


Compiling:

icpx -std=c++11 -I"/opt/intel/oneapi/dal/2024.2/include" kmeans_csr_batch.cpp \

/opt/intel/oneapi/dal/2024.2/lib/libonedal_core.a /opt/intel/oneapi/dal/2024.2/lib/libonedal_thread.a -ltbb -ltbbmalloc -lpthread -ldl


================= Outputs:

./a.out

First 10 cluster assignments:

6.000   

13.000   

10.000   

13.000   

2.000   

10.000   

14.000   

12.000   

0.000   

16.000   


First 10 dimensions of centroids:

0.000   17.591  221.550  247.660  0.000   0.000   0.000   251.242  198.940  275.132  

295.622  0.000   301.130  0.000   0.000   241.016  227.610  240.671  13.663  232.512  

0.000   176.864  8.716   81.896  267.711  0.000   119.484  194.743  254.148  277.185  

296.199  1.397   298.152  0.000   0.000   250.834  220.490  242.556  10.894  229.351  

50.570  0.000   3.184   0.000   0.000   0.000   109.437  251.547  158.588  156.905  

214.201  269.138  36.219  0.000   0.000   0.000   271.184  96.983  290.968  291.172  

239.117  9.445   263.682  252.275  63.190  158.667  134.671  0.262   282.645  272.034  

0.000   22.133  226.067  247.111  0.000   0.000   0.000   247.122  186.600  272.500  

0.000   250.866  2.537   265.390  0.000   70.780  228.524  60.793  56.049  0.000   

256.038  61.826  198.376  3.691   102.215  133.238  0.000   0.000   14.235  252.678  

192.914  218.764  221.193  284.716  263.708  217.655  267.497  0.000   255.373  296.678  

103.797  273.434  5.323   151.360  103.414  0.000   216.677  256.367  0.000   172.625  

237.199  263.852  2.651   52.791  0.000   252.533  0.000   89.185  0.000   111.401  

211.218  68.119  270.124  218.696  250.426  134.625  49.897  107.415  221.530  87.616   

219.977  34.038  5.532   298.008  0.000   0.000   283.653  269.853  16.502  21.992   

238.584  262.239  238.637  185.528  261.533  5.855   281.647  0.546   75.414  224.607  

0.902   230.499  0.000   236.451  1.152   231.416  248.324  202.881  193.681  10.150   

0.000   52.300  4.777   297.508  0.000   0.000   279.362  275.869  4.831   21.431   

1.266   153.261  253.445  274.302  286.631  8.402   0.513   0.000   1.435   0.000   

198.149  255.631  228.151  288.604  270.971  275.645  0.000   102.600  182.940  123.002  


Objective function value:

341785984.000




0 Kudos
Reply