To install support vector machines, go to the Playground (Ctrl+OW) in your Pharo image and execute the following Metacello script (select it and press Do-it button or Ctrl+D):
Metacello new
baseline: 'AISupportVectorMachines';
repository: 'github://pharo-ai/support-vector-machines/src';
load.If you want to add a dependency on support vector machines to your project, include the following lines into your baseline method:
spec
baseline: 'AISupportVectorMachines'
with: [ spec repository: 'github://pharo-ai/support-vector-machines/src' ].If you are new to baselines and Metacello, check out the Baselines tutorial on Pharo Wiki.
Here's an example of how to use soft margin SVM. For that, open a Playground (CMD+OW) in your Pharo image and execute this code (CMD+A) and then (CMD+PP)
inputMatrix :=#( #( 1 0 0 ) #( 1 1 1 ) #( 1 3 3 ) #( 1 4 4 ) ).
outputVector := #( 1 1 -1 -1 ).
model := AISupportVectorMachines new.
model regularizationStrenght: 10000.
model learningRate: 1e-6.
model maxEpochs: 5000.
model fitX: inputMatrix y: outputVector.
testInput := #( #( 1 -1 -1 ) #( 1 5 5 ) #( 1 6 6 ) #( 1 7 7 ) ).
model predict: testInput "#(1 -1 -1 -1)"To understand this example and the soft margin svm in general please refer to our Wiki.