How to use the mldb.createDataset function in mldb

To help you get started, we’ve selected a few mldb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mldbai / mldb / testing / MLDB-327-sum-aggregate.js View on Github external
// This file is part of MLDB. Copyright 2015 mldb.ai inc. All rights reserved.

/* Test of sum aggregate (MLDB-327). */

var mldb = require('mldb')
var unittest = require('mldb/unittest')

var dataset_config = {
    'type'    : 'sparse.mutable',
    'id'      : 'test',
};

var dataset = mldb.createDataset(dataset_config)

var ts = new Date();

function recordExample(row, x, y, label)
{
    dataset.recordRow(row, [ [ "x", x, ts ], ["y", y, ts], ["label", label, ts] ]);
}

// Very simple linear regression, with x = y
recordExample("ex1", 0, 0, "cat");
recordExample("ex2", 1, 1, "dog");
recordExample("ex3", 1, 2, "cat");

dataset.commit()

var resp = mldb.get("/v1/query", {q: "select label,sum(x),vertical_sum(y) from test group by label order by label"});
github mldbai / mldb / testing / MLDB-605-timestamp-query.js View on Github external
// This file is part of MLDB. Copyright 2015 mldb.ai inc. All rights reserved.

// Test for MLDB-605; timestamp queries

var mldb = require('mldb')
var unittest = require('mldb/unittest')

var dataset_config = {
    'type'    : 'sparse.mutable',
    'id'      : 'test',
};

var dataset = mldb.createDataset(dataset_config)

var ts1 = new Date("2015-01-01");
var ts2 = new Date("2015-01-02");
var ts3 = new Date("2015-01-03");

dataset.recordRow('row1_imp_then_click', [ [ "imp", 0, ts1 ], ["click", 0, ts2] ]);
dataset.recordRow('row2_click_then_imp', [ [ "click", 0, ts1 ], ["imp", 0, ts2] ]);
dataset.recordRow('row3_click_and_imp', [ [ "click", 0, ts1 ], ["imp", 0, ts1] ]);

dataset.commit()

var query1 = mldb.get('/v1/query',
                      { q: 'select * from test where latest_timestamp(imp) < latest_timestamp(click)',
                        format: 'table', headers: false });

plugin.log(query1);
github mldbai / mldb / testing / MLDB-565-classifier-details.js View on Github external
// This file is part of MLDB. Copyright 2015 mldb.ai inc. All rights reserved.

var mldb = require('mldb')
var unittest = require('mldb/unittest')

var dataset_config = {
    'type'    : 'sparse.mutable',
    'id'      : 'test',
};

var dataset = mldb.createDataset(dataset_config)

var ts = new Date("2015-01-01");

function recordExample(row, x, y)
{
    dataset.recordRow(row, [ [ "x", x, ts ], ["y", y, ts] ]);
}

// Very simple linear regression, with x = y
recordExample("ex1", 0, 0);
recordExample("ex2", 1, 1);
recordExample("ex3", 2, 2);
recordExample("ex4", 3, 3);

dataset.commit()
github mldbai / mldb / testing / MLDB-679-latest-get-variable.js View on Github external
// This file is part of MLDB. Copyright 2015 mldb.ai inc. All rights reserved.

// Test for MLDB-605; timestamp queries

var mldb = require('mldb')
var unittest = require('mldb/unittest')

var dataset_config = {
    'type'    : 'sparse.mutable',
    'id'      : 'test',
};

var dataset = mldb.createDataset(dataset_config)

var ts1 = new Date("2015-01-01");
var ts2 = new Date("2015-01-02");
var ts3 = new Date("2015-01-03");

dataset.recordRow('row1', [ [ "x", 0, ts1 ], ["x", 1, ts2], ["x", 2, ts3] ]);

dataset.commit()

var query1 = mldb.get('/v1/query', { q: 'SELECT * from test' });

plugin.log(query1);

unittest.assertEqual(query1.json[0].columns.length, 3);

var query2 = mldb.get('/v1/query', { q: 'SELECT x from test' });
github mldbai / mldb / testing / MLDB-1120-sparse-mutable-values.js View on Github external
// This file is part of MLDB. Copyright 2015 mldb.ai inc. All rights reserved.

var mldb = require('mldb')
var unittest = require('mldb/unittest')

var dataset_config = {
    type:    'sparse.mutable',
    id:      'test'
};

var dataset = mldb.createDataset(dataset_config);

var ts = new Date(2015, 01, 01);

// Check all lengths of strings
dataset.recordRow("rowa1", [ [ "a", "a", ts ] ]);
dataset.recordRow("rowa2", [ [ "ab", "ab", ts ] ]);
dataset.recordRow("rowa3", [ [ "abc", "abc", ts ] ]);
dataset.recordRow("rowa4", [ [ "abcd", "abcd", ts ] ]);
dataset.recordRow("rowa5", [ [ "abcde", "abcde", ts ] ]);
dataset.recordRow("rowa6", [ [ "abcdef", "abcdef", ts ] ]);
dataset.recordRow("rowa7", [ [ "abcdefg", "abcdefg", ts ] ]);

// Check all lengths of utf-8 strings
dataset.recordRow("rowb1", [ [ "é", "é", ts ] ]);
dataset.recordRow("rowb2", [ [ "éb", "éb", ts ] ]);
dataset.recordRow("rowb3", [ [ "ébc", "ébc", ts ] ]);

mldb

MarkLogic V6 REST API Driver for Node.js

Unrecognized
Latest version published 11 years ago

Package Health Score

36 / 100
Full package analysis