How to use mldb - 10 common examples

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 ] ]);
github mldbai / mldb / testing / MLDB-1500-transpose-query.js View on Github external
function createAndTrainProcedure(config, name)
{
    var start = new Date();

    var createOutput = mldb.put("/v1/procedures/" + name, config);
    assertSucceeded("procedure " + name + " creation", createOutput);

    // Run the training
    var trainingOutput = mldb.put("/v1/procedures/" + name + "/runs/1", {});
    assertSucceeded("procedure " + name + " training", trainingOutput);

    var end = new Date();

    plugin.log("procedure " + name + " took " + (end - start) / 1000 + " seconds");
}
github mldbai / mldb / testing / MLDB-1117-git-import.js View on Github external
function createAndRunProcedure(config, name)
{
    var start = new Date();

    var createOutput = mldb.put("/v1/procedures/" + name, config);
    assertSucceeded("procedure " + name + " creation", createOutput);

    // Run the training
    var trainingOutput = mldb.put("/v1/procedures/" + name + "/runs/1", {});
    assertSucceeded("procedure " + name + " training", trainingOutput);

    var end = new Date();

    plugin.log("procedure " + name + " took " + (end - start) / 1000 + " seconds");
}
github mldbai / mldb / testing / MLDB-529-duplicate-pin.js View on Github external
function createAndTrainProcedure(config, name)
{
    var createOutput = mldb.put("/v1/procedures/" + name, config);
    assertSucceeded("procedure " + name + " creation", createOutput);

    // Run the training
    var trainingOutput = mldb.put("/v1/procedures/" + name + "/runs/1", {});
    assertSucceeded("procedure " + name + " training", trainingOutput);
}
github mldbai / mldb / testing / MLDB-801-from-table-expression.js View on Github external
function createAndRunProcedure(config, name)
{
    var start = new Date();

    var createOutput = mldb.put("/v1/procedures/" + name, config);
    assertSucceeded("procedure " + name + " creation", createOutput);

    // Run the training
    var trainingOutput = mldb.put("/v1/procedures/" + name + "/runs/1", {});
    assertSucceeded("procedure " + name + " training", trainingOutput);

    var end = new Date();

    plugin.log("procedure " + name + " took " + (end - start) / 1000 + " seconds");
}
github mldbai / mldb / testing / MLDB-1755-column-execution-memory-use.js View on Github external
resp = mldb.put('/v1/procedures/benchmark', {
    "type": "randomforest.binary.train",
    "params": {
        "trainingData": "select {* EXCLUDING(dep_delayed_15min)} as features, dep_delayed_15min = 'Y' as label from airline",
        "runOnCreation": true,
        "modelFileUrl": "file://tmp/MLDB-1755.cls",
        "functionName": "classifyme",
        "featureVectorSamplings" : 1,
        "featureSamplings" : 1,
        "maxDepth" : 1,
        "verbosity" : 10,
        "featureSamplingProp": 1
    }
});

mldb.log(resp);

// Re-run but with all optimized paths turned off
// This causes us to not use the optimized column implementation
mldb.debugSetPathOptimizationLevel("never");

resp = mldb.put('/v1/procedures/benchmark2', {
    "type": "randomforest.binary.train",
    "params": {
        "trainingData": "select {* EXCLUDING(dep_delayed_15min)} as features, dep_delayed_15min = 'Y' as label from airline",
        "runOnCreation": true,
        "modelFileUrl": "file://tmp/MLDB-1433.cls",
        "functionName": "classifyme2",
        "featureVectorSamplings" : 1,
        "featureSamplings" : 1,
        "maxDepth" : 1,
        "verbosity" : 10,

mldb

MarkLogic V6 REST API Driver for Node.js

Unrecognized
Latest version published 12 years ago

Package Health Score

36 / 100
Full package analysis