-
Notifications
You must be signed in to change notification settings - Fork 3
/
new-testing.js
30 lines (20 loc) · 876 Bytes
/
new-testing.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
let fs = require('fs-extra')
let measurement = require('./src/app/measurement.js')
let beautify = require("json-beautify")
let params = process.argv
let feature = params.find(arg => arg.match(/feature\=/g))
let fold = params.find(arg => arg.match(/fold\=/g))
feature = feature ? feature.split('=')[1] : null
fold = fold ? parseInt(fold.split('=')[1]) : null
if (!feature || !fold) throw 'Parameter tidak lengkap.'
console.log(`[${feature}]`)
let result = {}
let classifier = 'knn' // pasti knn
result = measurement.measure(`k-${fold}`, feature, classifier)
if (!fs.existsSync(`./dist/partial-results`)) {
fs.mkdirSync(`./dist/partial-results/`)
}
if (!fs.existsSync(`./dist/partial-results/${feature}`)) {
fs.mkdirSync(`./dist/partial-results/${feature}`)
}
fs.writeFileSync(`./dist/partial-results/${feature}/fold-${fold}.json`, beautify(result, null, 2, 100))