Python Library
Python library for Akkio
pip install akkio
import akkio
akkio.api_key = 'YOUR-API-KEY-HERE'
# get your API key at https://app.akk.io/team-settings
# list models in your organization
models = akkio.get_models()['models']
for model in models:
print(model)
# list datasets in your organization
datasets = akkio.get_datasets()['datasets']
for dataset in datasets:
print(dataset)
# create a new empty dataset
new_dataset = akkio.create_dataset('python api test')
print(new_dataset)
# add rows to the dataset
import random
rows = []
for i in range(1000):
rows.append({
'x': random.random()
})
rows[-1]['y'] = rows[-1]['x'] > 0.5
akkio.add_rows_to_dataset(new_dataset['dataset_id'], rows)
# create a model
new_model = akkio.create_model(new_dataset['dataset_id'], ['y'], [], {'duration': 1})
print(new_model)
# make a prediction using the model
prediction = akkio.make_prediction(new_model['model_id'], [{'x': 0.1}, {'x':0.7}], explain=True)
print(prediction)
Create a new empty dataset.
input | description |
dataset_name | The name of your newly created dataset. |
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 all datasets in your organization.
Get a dataset.
input | description |
dataset_id | A dataset id |
Recalculate the field types for a dataset.
input | description |
dataset_id | A dataset id |
Delete a dataset.
input | description |
dataset_id | A dataset id |
Get all models in your organization.
Delete a model in your organization.
input | description |
model_id | A model id |
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 casesforce 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 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 2yr ago