Skip to content

Commit d8620be

Browse files
committed
Fix unused variable lint errors etc.
1 parent 12b4f71 commit d8620be

6 files changed

Lines changed: 55 additions & 29 deletions

File tree

js/data/mnist.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ export default class MNISTData extends FixData {
101101

102102
async _readyData() {
103103
this._cols = []
104-
for (let i = 0, p = 0; i < 28; i++) {
105-
for (let j = 0; j < 28; j++, p++) {
104+
for (let i = 0; i < 28; i++) {
105+
for (let j = 0; j < 28; j++) {
106106
this._cols.push(`${i},${j}`)
107107
}
108108
}

js/renderer/document.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default class DocumentScatterRenderer extends BaseRenderer {
5050

5151
testData() {
5252
const x = this.datas.x[0]
53-
const [words, idxs] = DocumentLoader.ordinal(x)
53+
const [words] = DocumentLoader.ordinal(x)
5454
return words
5555
}
5656

js/view/sdar.js

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,26 @@
11
import SDAR from '../../lib/model/sdar.js'
2+
import Controller from '../controller.js'
23

3-
var dispSDAR = (elm, platform) => {
4+
export default function (platform) {
5+
platform.setting.ml.draft = true
6+
platform.setting.ml.usage = 'Click and add data point. Click "fit" to update.'
7+
const controller = new Controller(platform)
48
const fitModel = () => {
5-
const p = +elm.select('[name=p]').property('value')
6-
const c = +elm.select('[name=c]').property('value')
79
const tx = platform.trainInput
8-
const model = new SDAR()
10+
const model = new SDAR(p.value)
911
const pred = []
10-
for (let i = 0; i < c; pred[i++] = []);
12+
for (let i = 0; i < c.value; pred[i++] = []);
1113
for (let d = 0; d < tx[0].length; d++) {
1214
const xd = tx.map(v => v[d])
13-
const p = model.predict(xd, c)
15+
const p = model.predict(xd, c.value)
1416
for (let i = 0; i < pred.length; i++) {
1517
pred[i][d] = p[i]
1618
}
1719
}
1820
platform.trainResult = pred
1921
}
2022

21-
elm.append('span').text('p')
22-
elm.append('input').attr('type', 'number').attr('name', 'p').attr('min', 1).attr('max', 1000).attr('value', 1)
23-
elm.append('input').attr('type', 'button').attr('value', 'Fit').on('click', fitModel)
24-
elm.append('span').text('predict count')
25-
elm.append('input')
26-
.attr('type', 'number')
27-
.attr('name', 'c')
28-
.attr('min', 1)
29-
.attr('max', 100)
30-
.attr('value', 100)
31-
.on('change', fitModel)
32-
}
33-
34-
export default function (platform) {
35-
platform.setting.ml.draft = true
36-
platform.setting.ml.usage = 'Click and add data point. Click "fit" to update.'
37-
dispSDAR(platform.setting.ml.configElement, platform)
23+
const p = controller.input.number({ label: 'p', min: 1, max: 1000, value: 1 })
24+
controller.input.button('Fit').on('click', fitModel)
25+
const c = controller.input.number({ label: 'predict count', min: 1, max: 100, value: 100 }).on('change', fitModel)
3826
}

lib/model/bms.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export default class BlurringMeanShift {
7070
* @returns {number[]} Predicted values
7171
*/
7272
predict() {
73-
let categories = 0
7473
const p = []
7574
for (let i = 0; i < this._c.length; i++) {
7675
let category = i
@@ -80,7 +79,6 @@ export default class BlurringMeanShift {
8079
break
8180
}
8281
}
83-
if (category === i) categories++
8482
p[i] = category
8583
}
8684
return p

lib/model/nns/onnx/operators/gemm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default {
2323
const layers = []
2424
let inputName = inputList[0]
2525
if (attrs.transA) {
26-
layers.push({ type: 'transpose', input: [inputName], name: inputName + '_t', axis: [1, 0] })
26+
layers.push({ type: 'transpose', input: [inputName], name: `${inputName}_t`, axis: [1, 0] })
2727
inputName += '_t'
2828
}
2929
const initializers = {}

tests/gui/view/sdar.test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { getPage } from '../helper/browser'
2+
3+
describe('timeseries prediction', () => {
4+
/** @type {Awaited<ReturnType<getPage>>} */
5+
let page
6+
beforeEach(async () => {
7+
page = await getPage()
8+
const taskSelectBox = page.locator('#ml_selector dl:first-child dd:nth-child(5) select')
9+
await taskSelectBox.selectOption('TP')
10+
const modelSelectBox = page.locator('#ml_selector .model_selection #mlDisp')
11+
await modelSelectBox.selectOption('sdar')
12+
})
13+
14+
afterEach(async () => {
15+
await page?.close()
16+
})
17+
18+
test('initialize', async () => {
19+
const methodMenu = page.locator('#ml_selector #method_menu')
20+
const buttons = methodMenu.locator('.buttons')
21+
22+
const p = buttons.locator('input:nth-of-type(1)')
23+
await expect(p.inputValue()).resolves.toBe('1')
24+
const count = buttons.locator('input:nth-of-type(3)')
25+
await expect(count.inputValue()).resolves.toBe('100')
26+
})
27+
28+
test('learn', async () => {
29+
const methodMenu = page.locator('#ml_selector #method_menu')
30+
const buttons = methodMenu.locator('.buttons')
31+
32+
const fitButton = buttons.locator('input[value=Fit]')
33+
await fitButton.dispatchEvent('click')
34+
35+
const svg = await page.waitForSelector('#plot-area svg')
36+
const path = await svg.waitForSelector('.tile-render path')
37+
const d = await path.getAttribute('d')
38+
expect(d.split('L')).toHaveLength(101)
39+
})
40+
})

0 commit comments

Comments
 (0)