LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

k-nearest neighbors in MLT - any example?

Hi, 

 

There are currently no example on the LabVIEW MLT about the k-NN vi.

We would like to use k-NN and would like to refer to some examples. 

We couldn't get the distance control VI to work, and we are a bit puzzled by the fact that "examples" only accepts 1D arrays (our data is 2400 vectors, each of size 1x256).

 

Our understanding of the VI is that "distance" specifies which type of norm, "examples" is the labeled data, "sample" is the new, unlabeled data. 

 

When running with the current setup, there seems to be an error with the distance control.

 

Thanks for your help in advance, 

 

 

N&A

0 Kudos
Message 1 of 13
(4,910 Views)

I haven't been able to find a specific example to reference you to, but this Community article has a pretty in depth explanation of the MLT along with some examples where K-NN may be used (I haven't had a chance to go through them all yet).

 

https://decibel.ni.com/content/docs/DOC-19328

 

Regards,

National Instruments
0 Kudos
Message 2 of 13
(4,878 Views)

Thank you. We came across that article in our search. 

We have a good grasp of how the algorithms in the MLT work, we wanted the details (for instance, k-NN only accepts 1D arrays as inputs, which puzzled us for a while - our input is 2400 vectors of size 256. We had to create clusters).

We got hold of the creater of the toolkit, who provided us with an example, so everything is fine.

 

Thanks again!

 

0 Kudos
Message 3 of 13
(4,866 Views)

Hi sorry to open this thread back up but having trouble with getting help from forum and from internet.


Am trying to get kNN working myself with a realtime input of data but not sure how to set my examples for it or where to get them from. Would you perhaps have any advice? 🙂

 

Kindest Regards,

Kelly

0 Kudos
Message 4 of 13
(4,628 Views)

Hi Kelly,

 

It looks like this thread is pretty old and noone has been active on it for quite some time.  For better visibility, as well as to help manage the amount of each type of issue that comes through, we request that you create a new thread for your issue.  You are welcome and encouraged to use this post as a reference though.

 

Have a great day!

 

Nick

Applications Engineer
National Instruments
0 Kudos
Message 5 of 13
(4,594 Views)

Thanks Nick,

 

At this stage I feel like I've posted all over the site 😕 I started 2 new threads alright during the week, this was a last resort! I shall wait and see if anyone replies to my other posts 🙂

 

Thanks,

 

Kelly

0 Kudos
Message 6 of 13
(4,586 Views)

Hi!

 

Have you found a way out about using k-NN in labview? If yes, can you kindly give me some details about using the same??

 

Thank you!!

0 Kudos
Message 7 of 13
(4,474 Views)

Hi Pallikaranai,

 


I attempted several more times to work with the MLT but couldn't find any way, even getting onto NI themselves who tried to help but couldn't. But, I did get help from a LabVIEW user and a paper that was able to help me use a method which would be quite similar to KNN. Basically I had databases of 'knocking' or 'tapping' data and I wanted to compare my live signal to these databases to see if it was a 'tap' or a 'knock'.

 

I put my live signal and database amplitudes thorugh this method:

 

Wavelet transform

Covariance

SVD

find log base 10 of Vector S of SVD

find Mean, Max and  Min values of this and add togther to find Value X

compare this value X to the same values of the databses after they were put through the same method and the smallest difference was the database

that the event belonged in.

 

I have also attached my code for my DB showing how I did it in LabVIEW. I hope its of help, it might not at all. NI had a look over this method themselves too

and they said it should be ok. Are you applying to a signal yourself or anything similar? 🙂

0 Kudos
Message 8 of 13
(4,463 Views)

Really appreciate your immediate reply. All I am trying to do is get an input sound, get a few statisctical features from it and using k-NN, classify. I have done this in matlab where in I just had to create the train, target and test data in the workspace and apply appropriate code. I have other parts of my project in labview and hence am keen on incorporating the k-nn classification part as well in it. I have my training data which is a 2D array(11 *9) and a target data(11*1) in an excel sheet. How do i give this to the k-nn vi (examples and class label) in MLT toolkit? About the testing part, since I am just extracting statistical features from the sound, I am assuming I just have to put them in an array and give it o the "new sample" input in the k-nn vi. I am kind of new to labview and am not very sure about array operations. 

 

Thank you,

Vysh 

0 Kudos
Message 9 of 13
(4,456 Views)

Hi Vysh,

 

No problem. Unfortunately I couldn't get the actual Machine Learning toolkit working at all.  So I never actaully got it working with training sets etc the way the toolkit setup.

😕 is your training data a sample of amplitudes or FFT? Or anything similar? An array is basically a mini database of information. With waveforms and array is every amplitude per window of the signal. i usually work with an array of 128 samples when I work with signals. If you want to attach your code, I can have a look and see if I can be of any help? 🙂

 

Kelly

0 Kudos
Message 10 of 13
(4,442 Views)