-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
66 lines (50 loc) · 1.5 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'use strict';
const SMOTE = require('./index.js');
test('generates points between vectors with identical values', () => {
const min = 1;
const max = 3;
const initialVectors = [
[min,min],
[max,max]
];
const smote = new SMOTE(initialVectors);
const newVectors = smote.generate(5);
for(let vector of newVectors) {
expect(vector[0] > min).toBe(true);
expect(vector[0] < max).toBe(true);
expect(vector[1] > min).toBe(true);
expect(vector[1] < max).toBe(true);
expect(vector[0]).toEqual(vector[1]);
}
});
test('generates points between vectors with mismatched values', () => {
const minX = 1;
const maxX = 3;
const minY = -2;
const maxY = 12;
const initialVectors = [
[minX,minY],
[maxX,maxY]
];
const smote = new SMOTE(initialVectors);
const newVectors = smote.generate(5);
for(let vector of newVectors) {
expect(vector[0] > 1).toBe(true);
expect(vector[0] < 3).toBe(true);
expect(vector[1] > -2).toBe(true);
expect(vector[1] < 12).toBe(true);
}
});
test('generates points between vectors with many dimensions', () => {
const initialVectors = [
[1,2,6,3,4,5,9,5,6,7,4],
[8,4,2,5,8,0,5,2,5,8,3]
];
const smote = new SMOTE(initialVectors);
const newVectors = smote.generate(5);
for(let vector of newVectors) {
for(let value of vector) {
expect(isNaN(value)).toBe(false);
}
}
});