The Charge Classifier service is a web API that allows an integrator to submit a charge to Convergence Research for classification using a machine-learning algorithm developed from the vast collection of classified charges housed internally. It is trained daily by the Convergence Research staff and models are re-built nightly.
The web API uses a Json Web Token method for authentication and accepts input/output in both XML and JSON. Once issued, tokens have a 24 hour validity period. The following is an example workflow of a classification request:
Although the models are re-built nightly, this should not result in an interuption of service. However, we reserve the following times for maintenance:
Support is available M-F from 8:00AM to 5:00PM for non-critical issues using the following contact information:
The API will recognize both XML and JSON for requests and responses. NOTE: Although very similar, there are slight differences in casing and word separation between the two formats. Please be sure to consult the object definitions.
Http Status codes are used to communicate the success or failure of any operation. The following status codes can be returned by the service:
The API uses content negotiation to determine whether json or xml is returned from an API call. If the format is not specified, JSON is the default response format.
The Content-type
and Accept
Http headers are what content negotiation uses to parse requests and serialize responses to the http content stream.
NOTE: You can mix and match the Accept
and Content-type
if you want a different response format from the request and vice-versa.
Here are some examples of using the Http request headers to dictate the format:
Host: ml.convergenceresearch.com
Content-type: application/json
Accept: application/json
Content-Length: 54
Host: ml.convergenceresearch.com
Content-type: application/xml
Accept: application/xml
Content-Length: 54
Host: ml.convergenceresearch.com
Content-type: application/xml
Accept: application/json
Content-Length: 54
All API method calls are to be made over https/ssl with the appropriate http verb. If you receive a 404 Not Found
http response, be sure to check
that the verb is correct.
Description: | This method is token request that issues integrators an API token valid for 24 hours. |
---|---|
Url: | api/classifier/requestjwttoken |
Http Verb: | POST |
Request Object: | TokenRequest |
Response Object | JwtSecurityToken |
Possible Status Codes: |
|
Remarks: | The response token MUST be attached as the Authorization Bearer header in all subsequent requests. The token is valid for 24 hours from issuance. |
Example Request: |
|
Example Response: |
|
Description: | This method provides status information about the API and can be used to check the status of the ML model. |
---|---|
Url: | api/classifier/checkstatus |
Http Verb: | GET |
Request Object: | N/A |
Response Object: | StatusResponse |
Possible Status Codes: |
|
Remarks: | Any response besides a 200 OK means the service is unavailable. A 202 Accepted response means to try again shortly as the model is being built. |
Example Request: |
|
Example Response |
|
Description: | The method will return the current stop words the API uses to format incoming text. This list is maintained by Convergence Research. |
---|---|
Url: | api/classifier/getstopwords |
Http Verb: | GET |
Request Object: | N/A |
Response Object: | Array of string |
Possible Status Codes: |
|
Remarks: | The response object is a list of strings |
Example Request: |
|
Example Response: |
|
Description: | This method provides information about the defined categories as well overall statistics regarding macro/micro accuracy, log loss and reduction. |
---|---|
Url: | api/classifier/categoryinfo |
Http Verb: | GET |
Request Object: | N/A |
Response Object: | CategoryDetails |
Possible Status Codes: |
|
Remarks: | The statistics also provide a list of the category names/ids. This is useful if you need to filter the categories to only the ones you are interested in when making a request. |
Example Request: |
|
Example Response: |
|
Description: | If there are terms you would like to be classified for future results, you can submit them through this method and they will be examined and trained. |
---|---|
Url: | api/classifier/trainingrequest |
Http Verb: | POST |
Request Object: | TrainingRequest |
Response Object: | TrainingResponse |
Possible Status Codes: |
|
Remarks: | The amount of items that can be submitted is based on how many requests you've made in the last 30 days at a 1-to-10 ratio. For example, if you've submitted 500 requests in the last 30 days, you can request training on 50 items. Items must be distinct. If you've already submitted an item for training and you resubmit it, it will reflect a status of 'AlreadyQueued' in the response object. |
Example Request: |
|
Example Response: |
|
Description: | This method performs the classification on the source text you submit and returns the categor(ies) that match. |
---|---|
Url: | api/classifier/criminal |
Http Verb: | POST |
Request Object: | ClassifierRequest |
Response Object: | ClassifierResponse |
Possible Status Codes: |
|
Remarks: | If the model is being re-built at the time of the call, you could receive a 202 response. You should re-submit the request and it should succeed. This only occurs during the maintenance window of 12:15 AM EST to 12:25 AM. |
Example Request: |
|
Example Response: |
|
All objects are serializable as both xml and json. Examples of each object can be downloaded for review. NOTE: TokenResponse is never returned as xml
regardless of the value of your Accept
header. Since TokenResponse is a Json Web Token it is always returned as JSON
The TokenRequest method issues Json Web Tokens to authenticated clients.
<request-token>
<api-name>chargeclassifier</api-name>
<key>E85B37C58958DA46AF0C487598596</key>
</request-token>
{
"apiname": "chargeclassifier",
"key": "E85B37C58958DA46AF0C487598596"
}
Field Name | Type | Required | XML Name | JSON Name | Comments |
---|---|---|---|---|---|
ApiName | string | api-name | apiname | This required field is always the static string chargeclassifier | |
Key | string | key | key | Your api key value is provided when your account is established |
This is a JSON-only object returned from a successfull call to RequestJWTToken
{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBUElLZXlJRCI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1Q.TC-6hk_0dC2t0vgtQ8ijGQlTG-CMK6L8C_B0avNM3Kc"}
Field Name | Type | Required | XML Name | JSON Name | Comments |
---|---|---|---|---|---|
token | string | N/A | token | This value is attached as your Authentication Bearer http header |
The object is the result of the call to CheckStatus
<status-response>
<status>Ready</status>
<message>Service is ready.</message>
</status-response>
{"status":"Ready","message":"Service is ready."}
Field Name | Type | Required | XML Name | JSON Name | Comments |
---|---|---|---|---|---|
ServiceStatus | enumeration see Comments | status | status |
One of the following values:
|
|
Message | string | message | message | Describes the ServiceStatus in more detail |
The object returned from a call to CategoryInfo. This object contains the statistics
<category-details>
<timestamp>2020-03-03T15:53:21.0770524-05:00</timestamp>
<all-statistics>
<macro-accuracy>95.9010%</macro-accuracy>
<micro-accuracy>97.0800%</micro-accuracy>
<log-loss>11.3987%</log-loss>
<log-reduction>88.2067%</log-reduction>
</all-statistics>
<categories />
</category-details>
{
"timestamp": "2020-03-03T15:53:21.0770524-05:00",
"allstatistics": {
"macroaccuracy": "95.9010%",
"microaccuracy": "97.0800%",
"logloss": "11.3987%",
"logreduction": "88.2067%"
},
"categories":[]
Field Name | Type | Required | XML Name | JSON Name | Comments |
---|---|---|---|---|---|
Timestamp | Date/Time | timestamp | timestamp | Informs caller as to when the statistics were generated | |
AllStatistics | object see Comments | all-statistics | allstatistics |
This object is a weighted average of all the categories' combined statistics.
The following statistics are included:
|
|
Categories | Array of CategoryDetail | categories | categories | This array of CategoryDetail objects contains every distinct category the learning machine uses |
The individual statistics and training information for a specific category.
<category-detail>
<category-id>80</category-id>
<name>Homicide Offenses</name>
<crime-against>
<attribute>Person</attribute>
</crime-against>
<train-count>142</train-count>
<status>Ready</status>
<training-started>2020-03-02T14:49:52.6852168-05:00</training-started>
<training-finished>2020-03-02T14:50:16.3838342-05:00</training-finished>
<statistics>
<macro-accuracy>97.0674%</macro-accuracy>
<micro-accuracy>97.8982%</micro-accuracy>
<log-loss>6.6123%</log-loss>
<log-reduction>90.9055%</log-reduction>
</statistics>
</category-detail>
{
"categoryid": 80,
"name": "Homicide Offenses",
"crimeagainst": ["Person"],
"traincount": 142,
"status": "Ready",
"trainingstarted": "2020-03-02T14:49:52.6852168-05:00",
"trainingfinished": "2020-03-02T14:50:16.3838342-05:00",
"statistics": {
"macroaccuracy": "97.0674%",
"microaccuracy": "97.8982%",
"logloss": "6.6123%",
"logreduction": "90.9055%"
}
}
Field Name | Type | Required | XML Name | JSON Name | Comments |
---|---|---|---|---|---|
CategoryId | integer | category-id | categoryid | This id can be used to select a specific category to include when calling the Criminal API method | |
CategoryName | integer | name | name | This name can be used to select a specific category to include when calling the Criminal API method | |
CrimeAgainst | array of enumeration | crime-against | crimeagainst |
An array of one or more values:
|
|
TrainingCount | integer | train-count | traincount | The number of distinct, trained corpus charges that have been classified | |
Status | enumeration see Comments | status | status |
The status of this category. One of the following values:
|
|
TrainingStart | Date/Time | training-started | trainingstarted | The time the model training for this category started | |
TrainingFinish | Date/Time | training-finished | trainingfinished | The time the model training for this category finished | |
Statistics | object see Comments | statistics | statistics |
This object is the category's statistics as calculated by the last training run.
The following statistics are included:
|
The list of text strings to be trained and incorporated into the machine learning model.
<training-request>
<charges>
<charge>Drunk in public</charge>
<charge>Panhandling without a license</charge>
<charge>Hunting game out of season</charge>
</charges>
</training-request>
{
"charges": [
"Drunk in public",
"Panhandling without a license",
"Hunting game out of season"
]
}
Field Name | Type | Required | XML Name | JSON Name | Comments |
---|---|---|---|---|---|
Charges | Array of string | charges | charges | The array is unbounded but the amount of charges that will be accepted for processing is based on the number of requests performed in a 30 day period. |
The response returned back to the caller when calling TrainingRequest
<training-response>
<items>
<item>
<status>AlreadyQueued</status>
<timestamp>2020-03-05T08:29:33.1158903-05:00</timestamp>
<charge-text>Drunk in public</charge-text>
</item>
<item>
<status>Accepted</status>
<timestamp>2020-03-05T08:29:33.1158903-05:00</timestamp>
<charge-text>Panhandling without a license</charge-text>
</item>
<item>
<status>OverLimit</status>
<timestamp>2020-03-05T08:29:33.1158903-05:00</timestamp>
<charge-text>Hunting game out of season</charge-text>
</item>
</items>
</training-response>
{
"items": [
{
"status": "AlreadyQueued",
"timestamp": "2020-03-05T08:29:33.1158903-05:00",
"chargetext": "Drunk in public"
},
{
"status": "Accepted",
"timestamp": "2020-03-05T08:29:33.1158903-05:00",
"chargetext": "Panhandling without a license"
},
{
"status": "OverLimit",
"timestamp": "2020-03-05T08:29:33.1158903-05:00",
"chargetext": "Hunting game out of season"
}
]
}
Field Name | Type | Required | XML Name | JSON Name | Comments |
---|---|---|---|---|---|
Items | Array of TrainingItem | items | items | For each item submitted in a TrainingRequest, the caller will receive one TrainingItem back in this array |
The object that is returned to the caller as response to a TrainingRequest. This informs the user about the status of the training request item(s).
<training-item>
<status>AlreadyQueued</status>
<timestamp>2020-03-05T08:40:08.8815843-05:00</timestamp>
<charge-text>Drunk in public</charge-text>
</training-item>
{
"status": "Accepted",
"timestamp": "2020-03-05T08:29:33.1158903-05:00",
"chargetext": "Panhandling without a license"
}
Field Name | Type | Required | XML Name | JSON Name | Comments |
---|---|---|---|---|---|
Status | enumeration see Comments | status | status |
Informs the caller about the status of the training request item. One of the following values:
|
|
Timestamp | Date/Time | timestamp | timestamp | The time when the training item was responded to by the system | |
ChargeText | string | charge-text | chargetext | The is the echo of the text submitted for training in the TrainingRequest |
This object is the caller request to classify a term.
<request>
<source-text>Failure to yield - accident</source-text>
<client-reference>558886868</client-reference>
<required-confidence>0.9</required-confidence>
<options>
<stop-words>
<word>walk</word>
<word>then</word>
<word>or</word>
</stop-words>
</options>
</request>
{
"sourcetext": "Failure to yield - accident",
"clientreference": "558886868",
"requiredconfidence": 0.9,
"options": {
"customstopwords": [
"walk",
"then",
"or"
]
},
"categoriestoevaluate": null,
"crimeagainst": null
}
Field Name | Type | Required | XML Name | JSON Name | Comments |
---|---|---|---|---|---|
SourceText | string | source-text | sourcetext | This is the term to be classified. Cannot be null or empty | |
ClientReference | string | client-reference | clientreference | This is an echo field that can be used to associate a result from the caller's prospective | |
RequiredConfidence | number/decimal | required-confidence | requiredconfidence | The minimum percentage value a category must match to be considered a classification. NOTE: If unset, the confidence level defaults to .95 | |
CategoriesToEvaluate | Array of int | categories-to-evaluate | categoriestoevaluate | If you wish to limit the list of categories to be evaulated, you can pass their category-ids here. NOTE: See the CategoryInfo method to find these ID values. If not provided, the classifier will apply ALL categories | |
CrimeAgainst | Array of enumeration | crime-against | crimeagainst | If you wish to limit the list of categories to be evaulated to a specific crime victim (EX: 'property' or 'person'), you can pass in a list of victims to be evaluated. NOTE: See the CategoryInfo method to find these enumeration values. If not provided, the classifier will apply ALL crime victims. | |
Options | object see ClassifierOptions | options | options | This object contains any options available when requesting a classification. |
Additional parameters to pass to a Classifier Request
<classifier-options>
<stop-words>
<word>walk</word>
<word>then</word>
<word>or</word>
</stop-words>
</classifier-options>
{
"customstopwords": [
"walk",
"then",
"or"
]
}
Field Name | Type | Required | XML Name | JSON Name | Comments |
---|---|---|---|---|---|
CustomStopWords | Array of string | stop-words | customstopwords | You can add additional stop words to be evaulated when submitting a classification. This will ADD to the stop word list. NOTE: See the GetStopWords method to find current stop words being used by the classifier. If not provided, the classifier will apply the default stop word list. |
You can use the examples below to see complete requests and responses for many of the service methods.
NOTE: You will need to call RequestJWTToken to obtain a valid JSON Web Token and then attach it to your request's Authentication Bearer
header for the API example calls to succeed.
File name | Format | Description |
---|---|---|
Classification Request | Fiddler HTTP Request | This file is a raw http request to the 'Criminal' classification method |
Classification Response | JSON | The JSON results of a call to the 'Criminal' method |
JWT Request | Fiddler HTTP Request | 'RequestJWTToken' method call request |
CategoryInfo Response | XML | Example 'CategoryStatistics' object returned as method call response |