Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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,
}
csv_conf = {
type: "import.text",
params: {
dataFileUrl : "https://raw.githubusercontent.com/datacratic/mldb-pytanic-plugin/master/titanic_train.csv",
outputDataset: {
id: "titanic2",
},
named: 'lineNumber() % 10'
}
}
mldb.put("/v1/procedures/csv_proc", csv_conf)
res = mldb.put("/v1/procedures/csv_proc/runs/0", {})
mldb.log(res);
unittest.assertEqual(res['responseCode'], 400);
unittest.assertEqual(res['json']['error'], "Duplicate row name(s) in tabular dataset: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9");
// Test correctness of parser
var correctnessConfig = {
type: 'text.csv.tabular',
id: 'correctness',
params: {
dataFileUrl: 'https://raw.githubusercontent.com/uniVocity/csv-parsers-comparison/master/src/main/resources/correctness.csv'
}
};
csv_conf = {
type: "import.text",
params: {
dataFileUrl : "https://raw.githubusercontent.com/uniVocity/csv-parsers-comparison/master/src/main/resources/correctness.csv",
{
"columns" : [
[ "width", 780, "2016-08-09T16:46:52Z" ]
],
"rowName" : "\"[\"\"AskReddit\"\"]\""
},
{
"columns" : [
[ "width", 757, "2016-08-09T16:46:52Z" ]
],
"rowName" : "\"[\"\"funny\"\"]\""
}
];
mldb.log(res)
unittest.assertEqual(mldb.diff(expected, res.json, false /* strict */), {},
"output was not the same as expected output in batch executor desc");
res = mldb.get('/v1/query', { q: 'select sum(horizontal_count({*})) as width from transpose(reddit) group by rowName() order by sum(horizontal_count({*})) asc, rowName() limit 2' });
//Check that we get smallest value first and second smallest second
expected = [
{
"columns" : [
[ "width", 1, "2016-08-09T16:46:52Z" ]
],
"rowName" : "\"[\"\"1000\"\"]\""
},
{
"columns" : [
function testQuery(query, expected) {
mldb.log("testing query", query);
var resp = mldb.get('/v1/query', {q: query, format: 'table'});
mldb.log("received", resp.json);
mldb.log("expected", expected);
unittest.assertEqual(resp.responseCode, 200);
unittest.assertEqual(resp.json, expected);
}
function testQuery(query, expected) {
mldb.log("testing query", query);
var resp = mldb.get('/v1/query', {q: query, format: 'table'});
mldb.log("received", resp.json);
mldb.log("expected", expected);
unittest.assertEqual(resp.responseCode, 200);
unittest.assertEqual(resp.json, expected);
}
function testQuery(query, expected) {
mldb.log("testing query", query);
var resp = mldb.get('/v1/query', {q: query, format: 'table'});
mldb.log("received", resp.json);
mldb.log("expected", expected);
unittest.assertEqual(resp.responseCode, 200);
unittest.assertEqual(resp.json, expected);
}
function testQuery(query, expected) {
mldb.log("testing query", query);
var resp = mldb.get('/v1/query', {q: query, format: 'table'});
mldb.log("received", resp.json);
mldb.log("expected", expected);
unittest.assertEqual(resp.responseCode, 200);
unittest.assertEqual(resp.json, expected);
}
function testQuery(query, expected) {
mldb.log("testing query", query);
var resp = mldb.get('/v1/query', {q: query, format: 'table'});
mldb.log("received", resp.json);
mldb.log("expected", expected);
unittest.assertEqual(resp.responseCode, 200);
unittest.assertEqual(resp.json, expected);
}
var resp = mldb.query('select [] as x');
mldb.log(resp);
unittest.assertEqual(resp[0].columns, expected);
resp = mldb.query('select {} as x')
mldb.log(resp);
unittest.assertEqual(resp[0].columns, undefined);
resp = mldb.get('/v1/query', {q: 'select * from transpose(select 1)'});
mldb.log(resp);
unittest.assertEqual(resp.responseCode, 400);
unittest.assertEqual(resp.json.error.indexOf("Expected to find a ')' parsing a table expression. This is normally because of not putting a sub-SELECT within '()' characters") != -1, true, resp.json.error);
"success"
}
}
var res = mldb.put("/v1/procedures/csv_proc", csv_conf)
mldb.log(res);
unittest.assertEqual(res["responseCode"], 201);
var res = mldb.put("/v1/procedures/csv_proc/runs/myrun", {});
mldb.log(res);
unittest.assertEqual(res['json']['status']['numLineErrors'], 0);
res = mldb.get('/v1/datasets/iris');
unittest.assertEqual(res['json']['status']['rowCount'], 150);
mldb.log(res);
res = mldb.get('/v1/datasets/iris/query', { limit: 10, format: 'table', orderBy: 'CAST (rowName() AS NUMBER)'});
mldb.log(res.json);
csv_conf = {
type: "import.text",
params: {
dataFileUrl : "https://raw.githubusercontent.com/datacratic/mldb-pytanic-plugin/master/titanic_train.csv",
outputDataset: {
id: "titanic",
},
runOnCreation: true,
}
}