Create Predictions
Once model training is completed, PayrollDetect is ready to generate predictions.
Batch vs. Real-Time Predictions
Batch predictions: For processing larger datasets, create batch predictions via POST /create_prediction
with the data you want predictions for. To get the results, you have to call the GET /results
endpoint after the prediction job has finished.
Real-time predictions: For quick, real-time predictions on smaller datasets, execute the POST /real_time_prediction
endpoint. This is ideal for individual or small batches of data where immediate results are needed. This endpoint does not require you to call the GET /results
endpoint afterwards.
Create predictions
To correctly identify anomalies, it is crucial that data is submitted with consistent form across training (upload) and predicitons (e.g., consistent level of aggregation, similar SubTypes and handling of missing/null-values).
More on this and examples in Core Concepts.
To create predictions, follow these steps:
- Execute
POST /create_prediction
orPOST /real_time_prediction
for real-time predictions, with a list of Dataset IDs. A Job ID will be returned (results returned directly for real-time predictions)
For (batch) POST /create_prediction
only:
- Use
GET /status
with the Job ID until a 200 status with "success" is returned, or use webhooks.
Create prediction schema
required | Array of objects (Prediction Dataset) non-empty Prediction datasets for which predictions should be made. |
object Details for the webhook endpoint to call when a job finishes. |
{- "datasets": [
- {
- "id": "12aad5ab-b516-4c3d-bdcb-30e5825f0dac",
- "payslips": [
- {
- "id": "a10ba26d-1d90-409e-ae19-624fb16bf551",
- "date": "2024-05-21",
- "employeeId": "9053ad3a-b930-4637-bf14-0c23d7198aed",
- "employeeGroups": [
- "Engineering",
- "Intern"
], - "transactions": [
- {
- "id": "53c1ec4e-c2b9-4621-a7a9-00d93761f3d3",
- "contractId": "9053ad3a-b930-4637-bf14-0c23d7198aed",
- "type": "overtime",
- "subType": "incomeTax",
- "amount": 1000,
- "unit": "EUR",
- "fromDate": "2024-05-01",
- "toDate": "2024-05-31",
- "rate": 200,
- "quantity": 5,
- "costUnits": [
- {
- "department": "Engineering",
- "project": "Project X",
- "location": "Stockholm"
}, - {
- "company": "Company ABC"
}
]
}
]
}
]
}
],
}
Starting a prediction job via a Presigned-URL
This method allows initiating prediction jobs through a presigned-url, enabling larger payloads.
- Obtain the Presigned URL and Job ID: Make a GET request to the
/presigned_url
with the query string parametertype=prediction
. You will receive a URL for the prediction-job and a related Job ID.
GET /presigned_url
curl -X GET "https://api.machine-learning-factory.stage.visma.com/pd/presigned_url?type=prediction" \
-H "Authorization: Bearer YOUR ACCESS TOKEN" \
-H "tenantId: YOUR_TENANT_ID"
Remove .stage
from base url for production environment.
-
Trigger the Prediction Job: Use the PUT request on the received URL, following the specified schema for predictions. This action will start the prediction job using the Job ID you received.
-
Check the Job Status: Monitor the status of the job using
GET /status
with your Job ID.