Skip to content

Commit

Permalink
update default options
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaspanel committed Dec 23, 2014
1 parent 46d57b4 commit 4ba3010
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 39 deletions.
40 changes: 21 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,24 @@ Possible kernels are:

Possible parameters/options are:

| Name | Default value(s) | Description |
|------------------|----------------------------------|-------------------------------------------------------------------------------------------------------|
| svmType | `C_SVC` | Used classifier |
| kernelType | `RBF` | Used kernel |
| c | `[0.01, 0.125, 0.5, 2]` | Cost for `C_SVC`, `EPSILON_SVR` and `NU_SVR`. Can be a `Number` or an `Array` of numbers |
| nu | `[0.01, 0.125, 0.5, 1]` | For `NU_SVC`, `ONE_CLASS` and `NU_SVR`. Can be a `Number` or an `Array` of numbers |
| epsilon | `[0.01, 0.125, 0.5, 1]` | For `EPSILON_SVR`. Can be a `Number` or an `Array` of numbers |
| degree | `[2,3,4]` | For `POLY` kernel. Can be a `Number` or an `Array` of numbers |
| gamma | `[0.001, 0.01, 0.125, 0.5]` | For `POLY`, `RBF` and `SIGMOID` kernels. Can be a `Number` or an `Array` of numbers |
| r | `[0.125, 0.5, 0, 1, 2]` | For `POLY` and `SIGMOID` kernels. Can be a `Number` or an `Array` of numbers |
| kFold | `4` | `k` parameter for [k-fold cross validation]( http://en.wikipedia.org/wiki/Cross-validation_(statistics)#k-fold_cross-validation). `k` must be >= 1. If `k===1` then entire dataset is use for both testing and training. |
| normalize | `true` | Whether to use [mean normalization](http://en.wikipedia.org/wiki/Normalization_(statistics)) during data pre-processing |
| reduce | `true` | Whether to use [PCA](http://en.wikipedia.org/wiki/Principal_component_analysis) to reduce dataset's dimensions during data pre-processing |
| retainedVariance | `0.99` | Define the acceptable impact on data integrity (require `reduce` to be `true`) |
| eps | `1e-3` | Tolerance of termination criterion |
| cacheSize | `1e2` | Cache size in MB. |
| shrinking | `true` | Whether to use the shrinking heuristics |
| probability | `false` | Whether to train a SVC or SVR model for probability estimates |
| Name | Default value(s) | Description |
|------------------|------------------------|-------------------------------------------------------------------------------------------------------|
| svmType | `C_SVC` | Used classifier |
| kernelType | `RBF` | Used kernel |
| c | `[0.01,0.125,0.5,1,2]` | Cost for `C_SVC`, `EPSILON_SVR` and `NU_SVR`. Can be a `Number` or an `Array` of numbers |
| nu | `[0.01,0.125,0.5,1]` | For `NU_SVC`, `ONE_CLASS` and `NU_SVR`. Can be a `Number` or an `Array` of numbers |
| epsilon | `[0.01,0.125,0.5,1]` | For `EPSILON_SVR`. Can be a `Number` or an `Array` of numbers |
| degree | `[2,3,4]` | For `POLY` kernel. Can be a `Number` or an `Array` of numbers |
| gamma | `[0.001,0.01,0.5]` | For `POLY`, `RBF` and `SIGMOID` kernels. Can be a `Number` or an `Array` of numbers |
| r | `[0.125,0.5,0,1]` | For `POLY` and `SIGMOID` kernels. Can be a `Number` or an `Array` of numbers |
| kFold | `4` | `k` parameter for [k-fold cross validation]( http://en.wikipedia.org/wiki/Cross-validation_(statistics)#k-fold_cross-validation). `k` must be >= 1. If `k===1` then entire dataset is use for both testing and training. |
| normalize | `true` | Whether to use [mean normalization](http://en.wikipedia.org/wiki/Normalization_(statistics)) during data pre-processing |
| reduce | `true` | Whether to use [PCA](http://en.wikipedia.org/wiki/Principal_component_analysis) to reduce dataset's dimensions during data pre-processing |
| retainedVariance | `0.99` | Define the acceptable impact on data integrity (require `reduce` to be `true`) |
| eps | `1e-3` | Tolerance of termination criterion |
| cacheSize | `1e2` | Cache size in MB. |
| shrinking | `true` | Whether to use the shrinking heuristics |
| probability | `false` | Whether to train a SVC or SVR model for probability estimates |

The example below shows how to use them:

Expand All @@ -128,7 +128,9 @@ var clf = new svm.SVM({
});
```

__Note__ : If at least one parameter has multiple values, [node-svm](https://github.com/nicolaspanel/node-svm/) will go through all possible combinations to see which one gives the best predictions (it performs grid-search to maximize [f-score](http://en.wikipedia.org/wiki/F1_score) for classification and minimize [Mean Squared Error](http://en.wikipedia.org/wiki/Mean_squared_error) for regression).
__Notes__ :
* If at least one parameter has multiple values, [node-svm](https://github.com/nicolaspanel/node-svm/) will go through all possible combinations to see which one gives the best predictions (it performs grid-search to maximize [f-score](http://en.wikipedia.org/wiki/F1_score) for classification and minimize [Mean Squared Error](http://en.wikipedia.org/wiki/Mean_squared_error) for regression).
* You can override default values using an `.nodesvmrc` file (JSON).


##Training
Expand Down
6 changes: 3 additions & 3 deletions lib/core/default-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ module.exports = {
// kernels parameters
'kernel-type': kernels.RBF,
'degree': [2,3,4], // for POLY kernel
'gamma': [0.001, 0.01, 0.125, 0.5], // for POLY, RBF and SIGMOID kernels
'r': [0.125, 0.5, 0, 1, 2], // for POLY and SIGMOID kernels
'gamma': [0.001, 0.01, 0.5], // for POLY, RBF and SIGMOID kernels
'r': [0.125, 0.5, 0, 1], // for POLY and SIGMOID kernels

// SVM specific parameters
'c': [0.01, 0.125, 0.5, 2], // cost for C_SVC, EPSILON_SVR and NU_SVR
'c': [0.01, 0.125, 0.5, 1, 2], // cost for C_SVC, EPSILON_SVR and NU_SVR
'nu': [0.01, 0.125, 0.5, 1], // for NU_SVC, ONE_CLASS and NU_SVR
'epsilon': [0.01, 0.125, 0.5, 1], // for EPSILON-SVR

Expand Down
34 changes: 17 additions & 17 deletions test/core/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ describe('Config', function () {
expect(config.svmType).to.be(svmTypes.C_SVC);
expect(config.kernelType).to.be(kernelTypes.RBF);
expect(config.degree).to.eql([]);
expect(config.gamma).to.eql([0.001, 0.03125, 0.125, 0.5, 1]);
expect(config.gamma).to.eql([ 0.001, 0.01, 0.5 ]);
expect(config.r).to.eql([]);
expect(config.c).to.eql([0.03125, 0.125, 0.5, 2, 8]);
expect(config.c).to.eql([ 0.01, 0.125, 0.5, 1, 2 ]);
expect(config.nu).to.eql([]);
expect(config.epsilon).to.eql([]);
});
Expand Down Expand Up @@ -55,10 +55,10 @@ describe('Config', function () {
expect(config.svmType).to.be(svmTypes.NU_SVC);
expect(config.kernelType).to.be(kernelTypes.RBF);
expect(config.degree).to.eql([]);
expect(config.gamma).to.eql([0.001, 0.03125, 0.125, 0.5, 1]);
expect(config.gamma).to.eql([ 0.001, 0.01, 0.5 ]);
expect(config.r).to.eql([]);
expect(config.c).to.eql([]);
expect(config.nu).to.eql([0.03125, 0.125, 0.5, 0.75, 1]);
expect(config.nu).to.eql([ 0.01, 0.125, 0.5, 1 ]);
expect(config.epsilon).to.eql([]);
});

Expand All @@ -76,11 +76,11 @@ describe('Config', function () {
expect(config.svmType).to.be(svmTypes.EPSILON_SVR);
expect(config.kernelType).to.be(kernelTypes.RBF);
expect(config.degree).to.eql([]);
expect(config.gamma).to.eql([0.001, 0.03125, 0.125, 0.5, 1]);
expect(config.gamma).to.eql([ 0.001, 0.01, 0.5 ]);
expect(config.r).to.eql([]);
expect(config.c).to.eql([0.03125, 0.125, 0.5, 2, 8]);
expect(config.c).to.eql([ 0.01, 0.125, 0.5, 1, 2 ]);
expect(config.nu).to.eql([]);
expect(config.epsilon).to.eql([0.03125, 0.125, 0.5, 2, 8]);
expect(config.epsilon).to.eql([ 0.01, 0.125, 0.5, 1 ]);
});

});
Expand All @@ -98,10 +98,10 @@ describe('Config', function () {
expect(config.svmType).to.be(svmTypes.NU_SVR);
expect(config.kernelType).to.be(kernelTypes.RBF);
expect(config.degree).to.eql([]);
expect(config.gamma).to.eql([0.001, 0.03125, 0.125, 0.5, 1]);
expect(config.gamma).to.eql([ 0.001, 0.01, 0.5 ]);
expect(config.r).to.eql([]);
expect(config.c).to.eql([0.03125, 0.125, 0.5, 2, 8]);
expect(config.nu).to.eql([0.03125, 0.125, 0.5, 0.75, 1]);
expect(config.c).to.eql([ 0.01, 0.125, 0.5, 1, 2 ]);
expect(config.nu).to.eql([ 0.01, 0.125, 0.5, 1 ]);
expect(config.epsilon).to.eql([]);
});

Expand All @@ -122,7 +122,7 @@ describe('Config', function () {
expect(config.degree).to.eql([]);
expect(config.gamma).to.eql([]);
expect(config.r).to.eql([]);
expect(config.c).to.eql([0.03125, 0.125, 0.5, 2, 8]);
expect(config.c).to.eql([ 0.01, 0.125, 0.5, 1, 2 ]);
expect(config.nu).to.eql([]);
expect(config.epsilon).to.eql([]);
});
Expand All @@ -141,9 +141,9 @@ describe('Config', function () {
expect(config.svmType).to.be(svmTypes.C_SVC);
expect(config.kernelType).to.be(kernelTypes.POLY);
expect(config.degree).to.eql([2,3,4]);
expect(config.gamma).to.eql([0.001, 0.03125, 0.125, 0.5, 1]);
expect(config.r).to.eql([0.125, 0.5, 0, 1, 2, 8]);
expect(config.c).to.eql([0.03125, 0.125, 0.5, 2, 8]);
expect(config.gamma).to.eql([ 0.001, 0.01, 0.5 ]);
expect(config.r).to.eql([0.125, 0.5, 0, 1]);
expect(config.c).to.eql([ 0.01, 0.125, 0.5, 1, 2 ]);
expect(config.nu).to.eql([]);
expect(config.epsilon).to.eql([]);
});
Expand All @@ -162,9 +162,9 @@ describe('Config', function () {
expect(config.svmType).to.be(svmTypes.C_SVC);
expect(config.kernelType).to.be(kernelTypes.SIGMOID);
expect(config.degree).to.eql([]);
expect(config.gamma).to.eql([0.001, 0.03125, 0.125, 0.5, 1]);
expect(config.r).to.eql([0.125, 0.5, 0, 1, 2, 8]);
expect(config.c).to.eql([0.03125, 0.125, 0.5, 2, 8]);
expect(config.gamma).to.eql([ 0.001, 0.01, 0.5 ]);
expect(config.r).to.eql([0.125, 0.5, 0, 1]);
expect(config.c).to.eql([ 0.01, 0.125, 0.5, 1, 2 ]);
expect(config.nu).to.eql([]);
expect(config.epsilon).to.eql([]);
});
Expand Down

0 comments on commit 4ba3010

Please sign in to comment.