3 Star 12 Fork 2

cloudopt/baize

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test.ts 997 Bytes
一键复制 编辑 原始数据 按行查看 历史
T-baby 提交于 2020-10-27 15:20 . Init project
import { Baize } from './baize'
import * as fs from 'fs';
import { parseFile } from 'fast-csv';
let baize = new Baize()
let data = baize.preProcessing("https://zz.bdstatic.com/linksubmit/push.js", 1, "script");
let model = fs.readFileSync("./model/baize_model.json", "utf-8");
baize.load(model);
console.log(data);
console.time("Forecast consumption time");
console.log(baize.predict(data));
console.timeEnd("Forecast consumption time");
let testTrainingSet: Array<Array<any>> = []
let testPredictions: Array<number> = []
parseFile("dataset/test_convert.csv", { skipLines: 1 })
.on("error", error => console.error(error))
.on("data", row => {
testPredictions.push(row.shift());
testTrainingSet.push(row);
})
.on("end", (rowCount: number) => {
console.log(`Test dataset successfully loaded ${rowCount} lines`);
console.log("Start evaluating the model..");
console.log(`acc: ${baize.acc(testTrainingSet, testPredictions)}`);
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/cloudopt/baize.git
git@gitee.com:cloudopt/baize.git
cloudopt
baize
baize
master

搜索帮助