From 8294c27ac43ca0388b27b8751fe2ef8fa3a027f3 Mon Sep 17 00:00:00 2001 From: Sebastian Rabenhorst Date: Thu, 12 Mar 2015 17:13:41 +0100 Subject: [PATCH] load data from db --- lib/util.js | 15 +++++++++++++++ package.json | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index 743c052..0afacd1 100644 --- a/lib/util.js +++ b/lib/util.js @@ -73,6 +73,21 @@ exports.loadCSVData = function (context, done) { .on('end', function () { done(); }); }; +exports.loadTestData = function (context, done) { + console.log('loadTestData'); + context.data = {}; + context.testData.forEach(function (testdata) { + var zone = testdata.zone; + context.data[zone] = context.data[zone] || []; + var record = {}; + testdata.data[0].beacons.forEach(function (beacon) { + record[beacon.major + '-' + beacon.minor] = beacon.rssi; + }); + context.data[zone].push(record); + }); + done(); +}; + exports.writeTrainData = function (context, done) { context.tempTrainFile = 'temp.train'; var train = context.model ? false : true; diff --git a/package.json b/package.json index 3c3ff2d..f84a062 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "svm-tools", "version": "1.0.0", "description": "Tools to generate SVM Models", - "main": "index.js", + "main": "lib/util.js", "bin": { "svm-gen": "svm-gen.js", "svm-test": "svm-test.js"