Skip to content

Commit

Permalink
Set the default predicted value at the beginning of the fit in CLUES (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ishii-norimi authored Jan 14, 2024
1 parent 3529fde commit 91430f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/model/clues.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class CLUES {
const T = Math.max(1, Math.round(this._alpha * n))
let smax = -Infinity

let clusters_star = null
let clusters_star = Array(n).fill(0)
let g_star = Infinity
let y = datas
for (let t = 1; t <= T; t++) {
Expand Down
13 changes: 13 additions & 0 deletions tests/lib/model/clues.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,17 @@ describe('clustering', () => {
const ri = randIndex(y, t)
expect(ri).toBeGreaterThan(0.9)
})

test('small data', () => {
const model = new CLUES(0.8)
const x = Matrix.random(5, 2, -0.1, 0.1).toArray()

model.fit(x)
const y = model.predict()
expect(y).toHaveLength(x.length)
expect(model.size).toBe(1)
for (let i = 0; i < y.length; i++) {
expect(y[i]).toBe(0)
}
})
})

0 comments on commit 91430f7

Please sign in to comment.