Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the default predicted value at the beginning of the fit in CLUES #755

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
})
})