Einstein Platform Services

Step 2: Train the Dataset

Training the dataset creates the model that delivers the predictions.

  1. Now that you’ve added the labeled images to the dataset, it’s time to train the dataset. In this command, replace <TOKEN> with your token and <DATASET_ID> with your dataset ID, and then run it. This command trains the dataset and creates a model with the name specified in the name parameter.
curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -F "name=Beach and Mountain Model" -F "datasetId=<DATASET_ID>" https://api.einstein.ai/v2/vision/train

The response contains information about the training status and looks like the following. Make a note of the modelId because you use this value in the next step.

{
  "datasetId": 1000038,
  "datasetVersionId": 0,
  "name": "Beach and Mountain Model",
  "status": "QUEUED",
  "progress": 0,
  "createdAt": "2019-02-21T21:10:03.000+0000",
  "updatedAt": "2019-02-21T21:10:03.000+0000",
  "learningRate": 0.001,
  "epochs": 0,
  "queuePosition": 1,
  "modelType": "image",
  "language": "N/A",
  "object": "training",
  "modelId": "X76USM4Q3QRZRODBDTUGDZEHJU",
  "trainParams": null,
  "trainStats": null
}
  1. Training a dataset can take a while depending on how many images the dataset contains. To get the training status, in this command, replace <TOKEN> with your token and <YOUR_MODEL_ID> with the model ID, and then run the command.
curl -X GET -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" https://api.einstein.ai/v2/vision/train/<YOUR_MODEL_ID>

The response returns the status of the training process. If it’s in progress, you see a status of RUNNING. When the training is complete, it returns a status of SUCCEEDED and a progress value of 1.

{
  "datasetId": 1000072,
  "datasetVersionId": 0,
  "name": "Beach and Mountain Model",
  "status": "SUCCEEDED",
  "progress": 1,
  "createdAt": "2019-02-21T22:08:52.000+0000",
  "updatedAt": "2019-02-21T22:10:20.000+0000",
  "modelId": "X76USM4Q3QRZRODBDTUGDZEHJU",
  "learningRate": 0.001,
  "epochs": 3,
  "modelType": "image",
  "language": "N/A",
  "object": "training",
  "trainParams": null,
  "trainStats": {
    "labels": 2,
    "examples": 99,
    "averageF1": 0.9321266968325792,
    "totalTime": "00:02:16:958",
    "transforms": {
        "toFlip": true,
        "toRotate": false,
        "cropLocation": "random"
        },
    "trainingTime": "00:02:13:664",
    "earlyStopping": false,
    "lastEpochDone": 3,
    "modelSaveTime": "00:00:01:871",
    "testSplitSize": 15,
    "trainSplitSize": 84,
    "datasetLoadTime": "00:00:03:270",
    "preProcessStats": null,
    "postProcessStats": null
  }
}

Tell Me More

After you create a model, you can retrieve metrics about the model, such as its accuracy, f1 score, and confusion matrix. You can use these values to tune and tweak your model. Use this call to get the model metrics.

curl -X GET -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" https://api.einstein.ai/v2/vision/models/<MODEL_ID>

The command returns a response similar to this one.

{
  "id": "X76USM4Q3QRZRODBDTUGDZEHJU",
  "metricsData": {
    "f1": [
        0.8571428571428571,
        0.75
    ],
    "labels": [
      "Mountains",
      "Beaches"
    ],
    "testAccuracy": 0.9333,
    "trainingLoss": 0.0637,
    "confusionMatrix": [
        [
            8,
            1
        ],
        [
            0,
            6
        ]
    ],
    "trainingAccuracy": 0.9814
  },
  "createdAt": "2019-02-21T22:19:25.000+0000",
  "language": "N/A",
  "object": "metrics"
}

To see the model metrics for each training iteration (epoch) performed to create the model, call the learning curve API. See Get Model Learning Curve.

Updated 3 months ago

Step 2: Train the Dataset


Training the dataset creates the model that delivers the predictions.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.