Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nlpist committed Oct 15, 2015
1 parent 6eeb4f9 commit 21f28df
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions test/utilsTest/PrecisionRecallTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
var should = require('should');
var mlutils = require('../../utils');
var _ = require('underscore');
require ('../sorted');

describe('PrecisionRecall object', function() {
it('correctly calculates precision, recall, etc.', function() {
Expand Down Expand Up @@ -41,6 +40,16 @@ describe('PrecisionRecall object', function() {
results['Recall'].should.equal(7/9)
});

it('uniqueaggregate', function() {
var pr = new mlutils.PrecisionRecall();
var ac = [['Greet',[1,5]], ['Offer',[0,5]], ['Greet',[0,6]], ['Offer',[9,15]], ['Greet',[0,9]]]
var output = pr.uniqueaggregate(ac)
output.length.should.equal(3)

var actual = pr.uniquecandidate(output)
_.isEqual(actual[0], ['Greet',[0,9]]).should.be.true
})

it('correctly calculates precision, recall, accuracy in sequence format.', function() {
var pr = new mlutils.PrecisionRecall();

Expand All @@ -62,9 +71,9 @@ describe('PrecisionRecall object', function() {

var stats = pr.addCasesHashSeq(expected, actual, 1);

stats['TP'].sorted().should.eql(['10 hours', '8 hours', 'Offer'])
stats['FP'].sorted().should.eql(['Salary'])
stats['FN'].sorted().should.eql(['Working Hours'])
_.isEqual(stats['TP'], ['10 hours', '8 hours', 'Offer']).should.equal(true)
_.isEqual(stats['FP'], ['Salary']).should.equal(true)
_.isEqual(stats['FN'], ['Working Hours']).should.equal(true)

var results = pr.retrieveStats()

Expand Down Expand Up @@ -144,6 +153,6 @@ describe('PrecisionRecall object', function() {
"Accept": { "Accept": [ "offer", "agree" ], "Offer": [ "i offer" ] },
"Reject": { "Reject": [ "reject", "decline" ] }}

pr.retrieveStats()['interdep'].should.eql(gold)
_.isEqual(pr.retrieveStats()['interdep'], gold).should.be.true
})
})

0 comments on commit 21f28df

Please sign in to comment.