Node.js Library
Node.js library for Akkio
API Keys
As noted in the code samples below, you must get your API keys and copy them into your API code. Those can be found under the team settings page at the bottom of the Akkio app.

Installation
npm install --save akkio
Example Usage
# get your API key at https://app.akkio.com/team-settings
const akkio = require('akkio')('your API key');
(async () => {
# create a new dataset
let newDataset = await akkio.createDataset('my new dataset');
# populate it with some toy data
let rows = [];
for (var i = 0; i < 1000; i++) {
let x = Math.random();
rows.push({
'x': x,
'value larger than 0.5': x > 0.5,
});
}
await akkio.addRowsToDataset(newDataset.dataset_id, rows);
# train a model
let model = await akkio.createModel(newDataset.dataset_id, ['value larger than 0.5'], [], {
duration: 1
});
# field importance
for (let field in model.field_importance) {
console.log('field:', field, 'importance:', model.field_importance[field]);
}
# model stats
for (let field of model.stats) {
for (let outcome of field) {
console.log(outcome);
}
}
# use the trained model to make predictions
let predictions = await akkio.makePrediction(model.model_id, [{
'x': 0.25
}, {
'x': 0.75
}], {
explain: true
});
console.log(predictions);
})();
Datasets
createDataset(dataset_name)
Create a new empty dataset.
input
description
dataset_name
The name of your newly created dataset.
addRowsToDataset(dataset_id, rows)
Add rows to a dataset.
input
description
dataset_id
A dataset id
rows
An array of rows to be added to the dataset in the following form:
[{ "field 1": "data", "field 2": "data" }, { ... }, ... ]
getDatasets()
Get all datasets in your organization.
getDataset(dataset_id)
Get a dataset.
input
description
dataset_id
A dataset id
parseDataset(dataset_id)
Recalculate the field types for a dataset.
input
description
dataset_id
A dataset id
deleteDataset(dataset_id)
Delete a dataset.
input
description
dataset_id
A dataset id
Models
getModels()
Get all models in your organization.
deleteModel(model_id)
Delete a model in your organization.
input
description
model_id
A model id
createModel(dataset_id, predict_fields, ignore_fields, params)
Create a model (requires a dataset).
input
description
dataset_id
A dataset id
predict_fields
An array of field names to predict (case sensitive)
ignore_fields
An array of field names to ignore (case sensitive) (optional)
params
A dict with default value of:
{
"duration": 10,
"extra_attention: false,
"force": false
}
duration
is the duration in seconds to be used for model training.
extra_attention
can be enabled to help with predicting rare cases
force
forces a new model to be created
makePrediction(model_id, data)
Make a prediction using your model and new data.
input
description
model_id
A model id
data
An array of rows to be predicted in the following form:
[{ "field 1": "data", "field 2": "data" }, { ... }, ... ]
Last updated
Was this helpful?