Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68650b6
commit 0b98a03
Showing
58 changed files
with
2,466 additions
and
2,952 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,9 @@ npm-debug.log | |
node_modules | ||
build | ||
.idea | ||
|
||
# vagrant | ||
Vagrantfile | ||
.vagrant | ||
|
||
test/reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"predef": [ | ||
"console", | ||
"describe", | ||
"it", | ||
"after", | ||
"afterEach", | ||
"before", | ||
"beforeEach" | ||
], | ||
|
||
"indent": 4, | ||
"node": true, | ||
"devel": true, | ||
|
||
"bitwise": false, | ||
"curly": false, | ||
"eqeqeq": true, | ||
"forin": false, | ||
"immed": true, | ||
"latedef": false, | ||
"newcap": true, | ||
"noarg": true, | ||
"noempty": false, | ||
"nonew": true, | ||
"plusplus": false, | ||
"regexp": false, | ||
"undef": true, | ||
"quotmark": "single", | ||
"strict": true, | ||
"trailing": true, | ||
"camelcase": true, | ||
|
||
"asi": false, | ||
"boss": true, | ||
"debug": false, | ||
"eqnull": true, | ||
"es5": false, | ||
"esnext": false, | ||
"evil": false, | ||
"expr": false, | ||
"funcscope": false, | ||
"globalstrict": false, | ||
"iterator": false, | ||
"lastsemic": false, | ||
"laxbreak": true, | ||
"laxcomma": false, | ||
"loopfunc": true, | ||
"multistr": false, | ||
"onecase": true, | ||
"regexdash": false, | ||
"scripturl": false, | ||
"smarttabs": false, | ||
"shadow": false, | ||
"sub": false, | ||
"supernew": true, | ||
"validthis": false, | ||
|
||
"nomen": false, | ||
"white": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"reduce" : false, | ||
"timeout": 10000 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
module.exports = function (grunt) { | ||
require('load-grunt-tasks')(grunt); | ||
grunt.initConfig({ | ||
gyp: { | ||
addon: {} | ||
}, | ||
simplemocha: { | ||
options: { | ||
reporter: 'spec', | ||
timeout: '5000' | ||
}, | ||
full: { | ||
src: ['test/**/*.spec.js'] | ||
}, | ||
short: { | ||
options: { | ||
reporter: 'dot' | ||
}, | ||
src: ['test/*.spec.js'] | ||
} | ||
}, | ||
jshint: { | ||
options: { | ||
jshintrc: '.jshintrc' | ||
}, | ||
files: [ | ||
'Gruntfile.js', | ||
'bin/*', | ||
'lib/**/*.js', | ||
'test/**/*.js', | ||
'examples/**/*.js', | ||
'!test/reports/**/*' | ||
] | ||
}, | ||
exec: { | ||
cover: { | ||
command: 'STRICT_REQUIRE=1 node node_modules/istanbul/lib/cli.js cover --dir ./test/reports node_modules/mocha/bin/_mocha -- -R dot test/**/*.spec.js' | ||
}, | ||
coveralls: { | ||
command: 'node node_modules/.bin/coveralls < test/reports/lcov.info' | ||
} | ||
}, | ||
watch: { | ||
files: ['<%= jshint.files %>'], | ||
tasks: ['jshint', 'simplemocha:short'] | ||
} | ||
}); | ||
grunt.registerTask('test', ['jshint', 'gyp:addon', 'simplemocha:full']); | ||
grunt.registerTask('cover', 'exec:cover'); | ||
grunt.registerTask('coveralls', 'exec:coveralls'); | ||
grunt.registerTask('travis', ['test', 'cover', 'coveralls']); | ||
|
||
grunt.registerTask('default', 'test'); | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
Simple example using C-SVC classificator (default) to predict the xor function | ||
Dataset : xor problem | ||
Note : because XOR dataset is to small, we set k-fold paramater to 1 to avoid cross validation | ||
**/ | ||
'use strict'; | ||
|
||
var nodesvm = require('../lib'); | ||
|
||
var xor = [ | ||
[[0, 0], 0], | ||
[[0, 1], 1], | ||
[[1, 0], 1], | ||
[[1, 1], 0] | ||
]; | ||
|
||
// initialize predictor | ||
var svm = new nodesvm.CSVC({ | ||
kFold: 1 | ||
}); | ||
|
||
svm.train(xor) | ||
.spread(function (model, report) { | ||
console.log('SVM trained. \nReport :\n%s', JSON.stringify(report, null, '\t')); | ||
|
||
console.log('Lets predict XOR values'); | ||
xor.forEach(function(ex){ | ||
var prediction = svm.predictSync(ex[0]); | ||
console.log('%d XOR %d => %d', ex[0][0], ex[0][1], prediction); | ||
}); | ||
}).done(function () { | ||
console.log('done.'); | ||
}); | ||
|
||
/* OUTPUT | ||
SVM trained. | ||
Report : | ||
{ | ||
"accuracy": 1, | ||
"fscore": 1, | ||
"recall": 1, | ||
"precision": 1, | ||
"class": { | ||
"0": { | ||
"precision": 1, | ||
"recall": 1, | ||
"fscore": 1 | ||
}, | ||
"1": { | ||
"precision": 1, | ||
"recall": 1, | ||
"fscore": 1 | ||
} | ||
}, | ||
"retainedVariance": 1 | ||
} | ||
Lets predict XOR values | ||
0 XOR 0 => 0 | ||
0 XOR 1 => 1 | ||
1 XOR 0 => 1 | ||
1 XOR 1 => 0 | ||
done. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
[[0, 0], 0], | ||
[[0, 1], 1], | ||
[[1, 0], 1], | ||
[[1, 1], 0] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.