Skip to content

Commit 0cb6e39

Browse files
author
bezzazi abir
committed
Merge af29087
2 parents 8505709 + af29087 commit 0cb6e39

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,48 @@
66

77

88
# support-vector-machines
9+
10+
## How to install it?
11+
12+
To install support vector machines, go to the Playground (Ctrl+OW) in your [Pharo](https://pharo.org/) image and execute the following Metacello script (select it and press Do-it button or Ctrl+D):
13+
14+
```Smalltalk
15+
Metacello new
16+
baseline: 'AISupportVectorMachines';
17+
repository: 'github://pharo-ai/support-vector-machines/src';
18+
load.
19+
```
20+
21+
## How to depend on it?
22+
23+
If you want to add a dependency on support vector machines to your project, include the following lines into your baseline method:
24+
25+
```Smalltalk
26+
spec
27+
baseline: 'AISupportVectorMachines'
28+
with: [ spec repository: 'github://pharo-ai/support-vector-machines/src' ].
29+
```
30+
31+
If you are new to baselines and Metacello, check out the [Baselines](https://github.com/pharo-open-documentation/pharo-wiki/blob/master/General/Baselines.md) tutorial on Pharo Wiki.
32+
33+
## How to use it?
34+
35+
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)
36+
37+
```st
38+
inputMatrix := AIMatrix from: #( #( 1 0 0 ) #( 1 1 1 ) #( 1 3 3 ) #( 1 4 4 ) ).
39+
outputVector := #( 1 1 -1 -1 ).
40+
41+
model := AISupportVectorMachinesSoftSGD new.
42+
model regularizationStrenght: 10000.
43+
model learningRate: 1e-6.
44+
model maxEpochs: 5000.
45+
46+
model fitX: inputMatrix y: outputVector.
47+
48+
testInput := AIMatrix from: #( #( 1 -1 -1 ) #( 1 5 5 ) #( 1 6 6 ) #( 1 7 7 ) ).
49+
50+
model predict: testInput "an AIMatrix(1 -1 -1 -1)"
51+
```
52+
53+
To understand this example and the soft margin svm in general please refer to our [Wiki](https://github.com/pharo-ai/wiki/blob/master/wiki/MachineLearning/Support-Vector-Machines.md).

0 commit comments

Comments
 (0)