Training a Model

Add text to a training set

After you've created your model, you need to feed it with text to train it. Your model is re-trained every time you add a text. Adding a text to a model is done by using /v1/records endpoint.

post
v1/records

https://api.kimola.com/cognitive/v1/records
Adds the record to the specified model's training set and re-trains the model.
Request
Response
Headers
Authorization
required
string
Your API key.
Body Parameters
modelId
required
integer
Model id.
content
required
string
Text.
tag
required
string
Text category used for training.
200: OK
Document successfully created.
{
"id": integer,
"model": object,
"content": string,
"summary": string,
"tag": string,
"length": integer,
"createdDate": string
}
400: Bad Request
There is no API key in the request header.
401: Unauthorized
There is an API key in the request header, but invalid.
403: Forbidden
API key does not have access to the data model.

In Python:

requests.post('https://api.kimola.com/cognitive/v1/records',
headers = {'Authorization': 'APIKey your_api_key_here'},
json = {'modelId': model_id_here,
'identifier': record_identifier_here,
'title': record_title_here,
'content': record_content_here,
'tag': record_tag_here})

Delete a text from training set

You can use /v1/documents/{id} endpoint if you want to delete a text from a training set. After a text is deleted, associated model is automatically re-trained.

delete
v1/records/{id}

https://api.kimola.com/cognitive/v1/records/{id}
Deletes the record from model's training set and re-trains the model.
Request
Response
Path Parameters
id
required
integer
Document id.
Headers
Authorization
required
string
Your API key.
200: OK
Document is successfully deleted
400: Bad Request
There is no API key in the request header.
401: Unauthorized
There is an API key in the request header, but invalid.
403: Forbidden
API key does not have access to the data model.

In Python:

requests.delete('https://api.kimola.com/cognitive/v!/records/{0}'.format(record_id_here))

Helper Endpoints

Retrieve Model Statistics

You can use v1/models/{id}/statistics endpoint to see a model's training set statistics.

get
v1/models/{id}/statistics

https://api.kimola.com/cognitive/v1/models/{id}/statistics
Provides statistics of the data model as a list of tags with their percentages.
Request
Response
Path Parameters
id
required
integer
Model id.
Headers
Authorization
optional
string
Your API key.
200: OK
The request is successful.
[
{
"tag": string,
"count": integer,
"ratio": integer,
"percentage": integer,
"mille": integer
}
.
.
.
]
400: Bad Request
There is no API key in the request header.
401: Unauthorized
There is an API key in the request header but invalid.
403: Forbidden
API key does not have access to the data model.

In Python:

model_statistics = requests.get('https://api.kimola.com/cognitive/v1/models/{0}/statistics'.format(model_id_here)).json()

Retrieve Record Details

You can retrieve a record's details by using /v1/records/{id} endpoint.

get
v1/records/{id}

https://api.kimola.com/cognitive/v1/records/{id}
Shows details of the specified document.
Request
Response
Path Parameters
id
required
integer
Document id.
Headers
Authorization
optional
string
Your API key.
200: OK
Document is found.
{
"id": integer,
"model": object,
"identifier": string,
"title": string,
"content": string,
"summary": string,
"summaryHtml": string,
"tag": string,
"length": integer,
"createdDate": string
}
400: Bad Request
There is no API key in the request header.
401: Unauthorized
There is an API key in the request header, but invalid.
403: Forbidden
API key does not have an access to the data model.

In Python:

record_details = requests.get('https://api.kimola.com/cognitive/v1/records/{0}'.format(record_id_here)).json()

You can test your model now!