Skip to content
Browse files

tiny tweaks for docs

  • Loading branch information...
1 parent 8b72655 commit f6ace868180f4471d07f2ecb58cccb57b5f3f9bc Andrej committed Jul 8, 2012
Showing with 6 additions and 4 deletions.
  1. +5 −3 README.md
  2. +1 −1 demo/demosvm.html
View
8 README.md
@@ -11,17 +11,19 @@ are in /test.
Can be found here: http://cs.stanford.edu/~karpathy/svmjs/demo/
-Code is inside /demo directory.
+Corresponding code is inside /demo directory.
## Usage
The simplest use case:
```javascript
// include the library
<script src="./svmjs/lib/svm.js"></script>
+<script>
svm = svmjs.SVM();
svm.train(data, labels);
testlabels = svm.predict(testdata);
+</script>
```
Here, `data` and `testdata` are a 2D, NxD array of floats, `labels` and `testlabels`
is an array of size N that contains 1 or -1. You can also query for the raw margins:
@@ -34,7 +36,7 @@ The library supports arbitrary kernels, but currently comes with linear and rbf
```javascript
svm.train(data, labels, { kernel: function(v1,v2){ /* return K(v1, v2) */} }); // arbitrary function
svm.train(data, labels, { kernel: svmjs.linearKernel });
-svm.train(data, labels, { kernel: svmjs.makeRbfKernel(0.5) });
+svm.train(data, labels, { kernel: svmjs.makeRbfKernel(0.5) }); // sigma = 0.5
```
For linear kernels, you can also query the weights and offset directly:
@@ -46,7 +48,7 @@ wb= svm.getWeights();
For training you can pass in several options. Here are the defaults:
```javascript
var options = {};
-/* Higher = you trust your data more. Lower = more regularization.
+/* For C, Higher = you trust your data more. Lower = more regularization.
Should be in range of around 1e-2 ... 1e5 at most. */
options.C = 1.0;
options.tol = 1e-4; // do not touch this unless you're pro
View
2 demo/demosvm.html
@@ -275,7 +275,7 @@
<div id="dec">
<br /><h1>Support Vector Machine in Javascript</h1>
<p>
-Uses SMO algorithm. Find code on <a href="">Github</a> <br />
+Uses SMO algorithm. Find code on <a href="https://github.com/karpathy/svmjs">Github</a> <br />
Find me on Twitter <a href="https://twitter.com/karpathy">@karpathy</a>
</p>
</div>

0 comments on commit f6ace86

Please sign in to comment.
Something went wrong with that request. Please try again.