adding parameters to the slkearn classifier Box

Making & changing box plugins and external apps
Post Reply
KJeffrey
Posts: 74
Joined: Wed Jul 20, 2022 6:47 pm

adding parameters to the slkearn classifier Box

Post by KJeffrey »

I would like to use the sklearn classifier box, specifically with the Support Vector Machine (SVM) option. The advantage of this I had hoped to avail myself of is the ability to optimize the SVM outside of OpenViBE using the sklearn Python SVM. Looking at the parameters available in the configuration, I do not see an option to change the kernel to polynomial or RBV. I can only assume that a linear kernel is assumed. Is there an easy way to modify this Box to support these kernel choices. If the Box relies on the sklearn SVM implementation, then might all the Python code be there under the surface and accessible?

Incidently, the OpenViBE SVM does allow changing the kernel.

Thanks,
-Jeff

Thomas
Posts: 211
Joined: Wed Mar 04, 2020 3:38 pm

Re: adding parameters to the slkearn classifier Box

Post by Thomas »

Hi Jeff,

Yes you are right, when selecting the SVM aglorithm in the sklearn box, the kernel is linear.

The class used is the svm.LinearSVC which is, as its name suggests, only linear.
Therefore, changing kernel is not just providing the parameter, but actually adding a new algorithm that would use the svm.SVC or svm.NuSVC.

The Pybox code as been pretty well architectured and I believe that adding such algorithm shouldn't be too complicated.

I have just read the scikit-learn documentation on the topic, and without more digging, I am not sure which algorithm makes more sense to be added.
Do you have any suggestions on which would be better to add ?

Thanks,
Thomas

KJeffrey
Posts: 74
Joined: Wed Jul 20, 2022 6:47 pm

Re: adding parameters to the slkearn classifier Box

Post by KJeffrey »

Thomas,

I have been using svm.SVC which allows these kernel choices: {‘linear’, ‘poly’, ‘rbf’, ‘sigmoid’, ‘precomputed’} or callable, default=’rbf’.
It seems odd to me that this more general implementation was not implemented already, as it includes a linear kernel as an option and gives you a lot more besides.

If we could get the svm.SVC put in a Box, that would be excellent! Then I could use the identical methods stand-alone and within OpenViBE. I just have to get Sebastian to get the PyBox working in OpenViBE.

This brings up another question that I may have posted elsewhere but will include here now. I need to select a subset of features, but the Feature Selector Box only seems to allow the selection of particular channels. I need to select particular times within particular frequency bands within particular channels. Is there a way to do that with existing Boxes, or will I need to write my own?

Thanks,
-Jeff

Thomas
Posts: 211
Joined: Wed Mar 04, 2020 3:38 pm

Re: adding parameters to the slkearn classifier Box

Post by Thomas »

Hi Jeff,

From scikit-learn documentation page, I read that the svm.LinearSVC is faster than the other implementations. That might be the reason why it was chosen over the others.
Although it is not in our priority tasks here, I have created a ticket to take not of the interest.

For the second part of your question:
The way OpenViBE works with most boxes means that indeed, that feature selection usually refers to channels.
However, using the Time Based Epoching or Stimulation Base Epoching boxes, you can select a particular time window in a channel, and the Temporal Filter box will allow you to work on specific frequency bands.

Of course depending on what you want to achieve, the complexity of the scenario might get high enough that you decide to write some more custom code. Note that you can prototype more easily with the Python box (sometimes it can also be a final working option).

Hope this helps.

Cheers,
Thomas

KJeffrey
Posts: 74
Joined: Wed Jul 20, 2022 6:47 pm

Re: adding parameters to the slkearn classifier Box

Post by KJeffrey »

Hi Thomas,

This info is helpful, thank you. I will look into your suggestions about selecting time windows, but I suspect it may be difficult to use as I need to select "random" time frames (samples) based on statistical significance, not time sub-epochs.

-Jeff

Post Reply