Python Library
Python library for Akkio

API Key

Installation

1
pip install akkio
Copied!

Example Usage

1
import akkio
2
akkio.api_key = 'YOUR-API-KEY-HERE'
3
# get your API key at https://app.akk.io/team-settings
4
5
# list models in your organization
6
models = akkio.get_models()['models']
7
for model in models:
8
print(model)
9
10
# list datasets in your organization
11
datasets = akkio.get_datasets()['datasets']
12
for dataset in datasets:
13
print(dataset)
14
15
# create a new empty dataset
16
new_dataset = akkio.create_dataset('python api test')
17
print(new_dataset)
18
19
# add rows to the dataset
20
import random
21
rows = []
22
for i in range(1000):
23
rows.append({
24
'x': random.random()
25
})
26
rows[-1]['y'] = rows[-1]['x'] > 0.5
27
akkio.add_rows_to_dataset(new_dataset['dataset_id'], rows)
28
29
# create a model
30
new_model = akkio.create_model(new_dataset['dataset_id'], ['y'], [], {'duration': 1})
31
print(new_model)
32
33
# make a prediction using the model
34
prediction = akkio.make_prediction(new_model['model_id'], [{'x': 0.1}, {'x':0.7}], explain=True)
35
print(prediction)
Copied!

Datasets

create_dataset(dataset_name)

Create a new empty dataset.
input
description
dataset_name
The name of your newly created dataset.

add_rows_to_dataset(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" }, { ... }, ... ]

get_datasets()

Get all datasets in your organization.

get_dataset(dataset_id)

Get a dataset.
input
description
dataset_id
A dataset id

parse_dataset(dataset_id)

Recalculate the field types for a dataset.
input
description
dataset_id
A dataset id

delete_dataset(dataset_id)

Delete a dataset.
input
description
dataset_id
A dataset id

Models

get_models()

Get all models in your organization.

delete_model(model_id)

Delete a model in your organization.
input
description
model_id
A model id

create_model(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
Sometimes creating models can take a while, especially if this is the first time creating a model on this dataset. create_model is idempotent and can be called multiple times with the same parameters.

make_prediction(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 modified 8mo ago