Samples

Sample Sets

Sample Sets group Samples within a Function. Each Sample Set can either contribute to training or be excluded from it. The default Sample Set contributes to training; accuracy on it is reported via cross-validation. Use these calls to move a Sample in or out of a named Sample Set.

There are two ways to call this operation:

Add to a sample set

POST /v1/functions/{functionId}/samples/{sampleId}/sample-sets

Description

Adds the Sample to the named Sample Set. The Sample Set is created on-the-fly if it does not already exist.

Path parameters

NameTypeRequiredDescription
functionId string yes

—

sampleId string yes

—

Request body

Content type: application/json.

FieldTypeRequiredDescription
sampleSetId string nullable no

—

weight integer nullable no

—

Responses

StatusDescriptionBody
200 Success SampleSetRelationship

Code samples

curl
curl -X POST \
  -H 'Authorization: Bearer <accessToken>' \
  -H 'Content-Type: application/json' \
  -d '{
  "sampleSetId": "<sampleSetId>",
  "weight": 0
}' \
  'https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/sample-sets'
Python
import requests

url = 'https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/sample-sets'
headers = {
    'Authorization': 'Bearer <accessToken>',
    'Content-Type': 'application/json',
}

body = """{
  "sampleSetId": "<sampleSetId>",
  "weight": 0
}"""
response = requests.post(url, headers=headers, data=body)
print(response.json())
JavaScript
fetch('https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/sample-sets', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <accessToken>',
    'Content-Type': 'application/json',
  },
  body: `{
  "sampleSetId": "<sampleSetId>",
  "weight": 0
}`,
})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/sample-sets');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

$headers = array(
    'Authorization: Bearer <accessToken>',
    'Content-Type: application/json',
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$body = <<<'NYCKEL_BODY'
{
  "sampleSetId": "<sampleSetId>",
  "weight": 0
}
NYCKEL_BODY;
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);
curl_close($ch);
echo $response;

Related

Remove from a sample set

DELETE /v1/functions/{functionId}/samples/{sampleId}/sample-sets/{sampleSetId}

Description

Removes the Sample from the named Sample Set. The Sample itself remains in the Function; only its membership in this Sample Set is severed.

Path parameters

NameTypeRequiredDescription
functionId string yes

—

sampleId string yes

—

sampleSetId string yes

The sample set to delete

Responses

StatusDescriptionBody
200 Success —

Code samples

curl
curl -X DELETE \
  -H 'Authorization: Bearer <accessToken>' \
  'https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/sample-sets/<sampleSetId>'
Python
import requests

url = 'https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/sample-sets/<sampleSetId>'
headers = {
    'Authorization': 'Bearer <accessToken>',
}

response = requests.delete(url, headers=headers)
print(response.json())
JavaScript
fetch('https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/sample-sets/<sampleSetId>', {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer <accessToken>',
  },
})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/sample-sets/<sampleSetId>');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');

$headers = array(
    'Authorization: Bearer <accessToken>',
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
curl_close($ch);
echo $response;