Skip to content

Commit 4093dbc

Browse files
committed
Small improve
1 parent dd851fe commit 4093dbc

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/util/math.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,14 +1500,15 @@ export class Matrix {
15001500
/**
15011501
* Shuffle values along the axis.
15021502
* @param {number} [axis=0]
1503+
* @returns {number[]} Original index.
15031504
*/
15041505
shuffle(axis = 0) {
15051506
const idx = []
15061507
for (let i = 0; i < this._size[axis]; i++) {
15071508
idx[i] = i
15081509
}
15091510
for (let i = idx.length - 1; i > 0; i--) {
1510-
let r = Math.floor(Math.random() * (i + 1))
1511+
const r = Math.floor(Math.random() * (i + 1))
15111512
;[idx[i], idx[r]] = [idx[r], idx[i]]
15121513
}
15131514

@@ -1516,6 +1517,7 @@ export class Matrix {
15161517
} else if (axis === 1) {
15171518
this._value = this.col(idx)._value
15181519
}
1520+
return idx
15191521
}
15201522

15211523
/**

tests/lib/model/confidence_weighted.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { jest } from '@jest/globals'
2+
jest.retryTimes(3)
3+
14
import { Matrix } from '../../../lib/util/math.js'
25
import { ConfidenceWeighted, SoftConfidenceWeighted } from '../../../lib/model/confidence_weighted.js'
36

0 commit comments

Comments
 (0)