Permalink
Browse files

remove the last submodule (brain)

  • Loading branch information...
erelsgl committed Sep 29, 2013
1 parent 4f2be30 commit 27ea3a4ac7106ed3e8c13acc897f1e2c8f3ecf56
View
@@ -1,3 +0,0 @@
[submodule "classifiers/brain"]
path = classifiers/brain
url = git://github.com/erelsgl/brain.git
@@ -17,7 +17,7 @@ var hash = require('../utils/hash');
* * 'multiplyFeaturesByIDF' - boolean - if true, multiply each feature value by log(documentCount / (1+featureDocumentFrequency))
* * 'minFeatureDocumentFrequency' - int - if positive, ignore features that appeared less than this number in the training set.
* * 'pastTrainingSamples' - an array that keeps all past training samples, to enable retraining.
* * 'spellChecker' - an initialized 'wordsworth' spell checker, to spell-check features during classification.
* * 'spellChecker' - an initialized spell checker from the 'wordsworth' package, to spell-check features during classification.
* * 'bias' - a 'bias' feature with a constant value (usually 1).
*/
var EnhancedClassifier = function(opts) {
Submodule brain deleted from 74a4ca
View
@@ -1,6 +1,7 @@
module.exports = {
// basic classifiers:
NeuralNetwork: require('./brain/lib/neuralnetwork').NeuralNetwork,
//NeuralNetwork: require('./brain/lib/neuralnetwork').NeuralNetwork,
NeuralNetwork: require('./neural/NeuralNetwork'),
Bayesian: require('./bayesian/bayesian'),
SvmJs: require('./svm/SvmJs'),
@@ -0,0 +1,14 @@
/**
* A wrapper for Heather Arthur's brain.js package: https://github.com/harthur/brain
*
* @author Erel Segal-haLevi
* @since 2013-09-29
*/
var NeuralNetwork = require('brain').NeuralNetwork;
NeuralNetwork.prototype.trainOnline = function () {throw new Error("NeuralNetwork does not support online training");}
NeuralNetwork.prototype.trainBatch = NeuralNetwork.prototype.train;
NeuralNetwork.prototype.classify = NeuralNetwork.prototype.run;
module.exports = NeuralNetwork;
View
@@ -10,12 +10,14 @@
"dependencies": {
"underscore": "*",
"sprintf": "*",
"wordsworth": "*",
"graph-paths": "*",
"svm": "*",
"temp": "*",
"execSync": "*",
"svm": "*",
"languagemodel": "latest"
"brain": "*",
"graph-paths": "*",
"languagemodel": "*"
},
"devDependencies": {
"mocha": ">=1.0.0",
@@ -9,40 +9,51 @@ var should = require('should');
var classifiers = require('../../classifiers');
var FeaturesUnit = require('../../features');
describe('baseline - classifier without a spell-checker', function() {
it('should not classify sentences with spelling mistakes', function() {
var spamClassifier = new classifiers.EnhancedClassifier({
classifierType: classifiers.NeuralNetwork,
featureExtractor: FeaturesUnit.WordsFromText(1),
spellChecker: null,
});
try {
var wordsworth = require('wordsworth');
var isTestRelevant = true;
} catch (e) {
console.warn("WARNING: Cannot load Spell-checker module (wordsworth) - can't run spell-checker unit test. The error is:");
console.dir(e);
var isTestRelevant = false;
}
spamClassifier.trainBatch([
{input: "cheap watches", output: [1]},
{input: "", output: [0]},
]);
spamClassifier.classify("cheap watches").should.be.above(0.6); // (spam)
spamClassifier.classify("cheep watchs").should.be.below(0.4); // (not spam)
spamClassifier.classify("expensive clocks").should.be.below(0.4); // (not spam)
if (isTestRelevant) {
describe('baseline - classifier without a spell-checker', function() {
it('should not classify sentences with spelling mistakes', function() {
var spamClassifier = new classifiers.EnhancedClassifier({
classifierType: classifiers.NeuralNetwork,
featureExtractor: FeaturesUnit.WordsFromText(1),
spellChecker: null,
});
spamClassifier.trainBatch([
{input: "cheap watches", output: [1]},
{input: "", output: [0]},
]);
spamClassifier.classify("cheap watches").should.be.above(0.6); // (spam)
spamClassifier.classify("cheep watchs").should.be.below(0.4); // (not spam)
spamClassifier.classify("expensive clocks").should.be.below(0.4); // (not spam)
})
})
})
describe('classifier with spell-checker', function() {
it('should classify sentences with spelling mistakes', function() {
var spamClassifier = new classifiers.EnhancedClassifier({
classifierType: classifiers.NeuralNetwork,
featureExtractor: FeaturesUnit.WordsFromText(1),
spellChecker: require('wordsworth').getInstance(),
});
spamClassifier.trainBatch([
{input: "cheap watches", output: [1]},
{input: "", output: [0]},
]);
spamClassifier.classify("cheap watches").should.be.above(0.9); // (spam)
spamClassifier.classify("cheep watchs").should.be.above(0.9); // (not spam)
spamClassifier.classify("expensive clocks").should.be.below(0.4); // (not spam)
describe('classifier with spell-checker', function() {
it('should classify sentences with spelling mistakes', function() {
var spamClassifier = new classifiers.EnhancedClassifier({
classifierType: classifiers.NeuralNetwork,
featureExtractor: FeaturesUnit.WordsFromText(1),
spellChecker: wordsworth.getInstance(),
});
spamClassifier.trainBatch([
{input: "cheap watches", output: [1]},
{input: "", output: [0]},
]);
spamClassifier.classify("cheap watches").should.be.above(0.9); // (spam)
spamClassifier.classify("cheep watchs").should.be.above(0.9); // (not spam)
spamClassifier.classify("expensive clocks").should.be.below(0.4); // (not spam)
})
})
})
}

0 comments on commit 27ea3a4

Please sign in to comment.