Download Recommendations
Available Guides
Reference:
| Field | Description |
|---|---|
| id | A unique random generated UUID as the key id for the Recommendation. |
| source | User, workload, Docker App or Kelvin SmartApp™ that created the Recommendation in KRN format. The KRN format is krn:{nid}:{nss} |
| resource | Asset in KRN format. The KRN format is krn:asset:<asset_name> |
| state | The current state of the Recommendation (pending, accepted, rejected, applied, expired, error) |
| description | Detailed description of the Recommendation. |
| actions | An array of objects with Control Change information. If the Recommendation is pending, it will display creation information or if the Recommendation is accepted or applied it will show the Control Change status. Each Control Change does not need to be related to the resource of the Recommendation. |
| confidence | Confidence level of the Recommendation. This is usually, but not mandatory, related to any machine learning model confidence results. |
| created | UTC time when the Recommendation was created, formatted in ISO 8601. |
| updated | UTC time when any Recommendation keys were last updated, formatted in ISO 8601. |
| payload | New value to write to resource |
| metadata | Custom dictionary keys/values for use by clients for anything useful and related to the Recommendation. |
| resource_parameters | Used for Internal use. |
| type | The Recommendation Type name associated with the Recommendation. |
| type_title | The Recommendation Type title of its name associated with the Recommendation. |
| logs | A date ordered list of the updates performed on this Recommendation. |
Download Recommendations for an Asset
In this example we will get a list of all Recommendation for the Asset pcp_01.
It is not possible export Recommendation from Kelvin UI. You can only view them.
curl -X "POST" \
"https://<url.kelvin.ai>/api/v4/recommendations/range/get" \
-H "Authorization: Bearer <Your Current Token>" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"start_date": "2024-08-01T12:00:00.000000Z",
"end_date": "2024-08-02T12:00:00.000000Z",
"resources": [
"krn:asset:pcp_01"
],
"sources": [
"krn:app:pcp-optimization"
],
"states": [],
"types": []
}'
You will receive a response body with a status code of 200, indicating a successful operation. For example, the response body might look like this:
{
"pagination": {
"next_page": "W3siS2V5IjoiaWQiLCJWYWx1ZSI6IjM2NWFlNGU0LWZiMGItNGJhZS1iODcxLTBkMjk4YTZjN2I1NCJ9XQ==",
"previous_page": null
},
"data": [
{
"id": "0190466b-5540-40cc-990b-7ca580139a20",
"source": "krn:wlappv:sales-01-cluster/pcp-optimization-d2tmv6s14vzz:pcp-optimization/1.0.202403041506",
"resource": "krn:asset:pcp_01",
"state": "auto_accepted",
"description": "Casing Pressure Event Detected, no changes allowed",
"actions": {},
"created": "2024-08-02T11:59:51.213148Z",
"updated": "2024-08-02T11:59:51.213148Z",
"expiration_date": "2024-08-02T19:59:46.788691Z",
"metadata": {},
"resource_parameters": {
"dd_rate_max": 123,
"dd_rate_min": 0.1,
"faulty_gauge": false,
"kelvin_control_mode": "Closed",
"lock_mode": false
},
"type": "no_action",
"type_title": "No Action",
"logs": [
{
"source": "krn:wlappv:sales-01-cluster/pcp-optimization-d2tmv6s14vzz:pcp-optimization/1.0.202403041506",
"state": "auto_accepted",
"created_at": "2024-08-02T11:59:51.213148Z"
}
]
},
{
"id": "03c9f4aa-b302-4c3e-8371-92e8dd03d606",
"source": "krn:wlappv:sales-01-cluster/pcp-optimization-d2tmv6s14vzz:pcp-optimization/1.0.202403041506",
"resource": "krn:asset:pcp_01",
"state": "auto_accepted",
"description": "Above max Drawdown, parameters stable",
"actions": {},
"created": "2024-08-02T00:44:46.356244Z",
"updated": "2024-08-02T00:44:46.356244Z",
"expiration_date": "2024-08-02T08:44:38.724014Z",
"metadata": {},
"resource_parameters": {
"dd_rate_max": 123,
"dd_rate_min": 0.1,
"faulty_gauge": false,
"kelvin_control_mode": "Closed",
"lock_mode": false
},
"type": "no_action",
"type_title": "No Action",
"logs": [
{
"source": "krn:wlappv:sales-01-cluster/pcp-optimization-d2tmv6s14vzz:pcp-optimization/1.0.202403041506",
"state": "auto_accepted",
"created_at": "2024-08-02T00:44:46.356244Z"
}
]
}
]
}
from kelvin.api.client import Client
# Login
client = Client(config={"url": "https://<url.kelvin.ai>", "username": "<your_username>"})
client.login(password="<your_password>")
# Get Range of Recommendations
response = client.recommendation.get_recommendation_range(
data={
"start_date": "2024-08-01T12:00:00.000000Z",
"end_date": "2024-08-02T12:00:00.000000Z",
"resources": [
"krn:asset:pcp_01",
],
"sources": [
"krn:app:pcp-optimization",
],
"states": [],
"types": [],
}
)
# Convert the response into a Pandas DataFrame
df = response.to_df()
df = df[["type", "state", "resource", "description"]]
# Print the result
print(df)
The response file will look something like this;
type state resource
0 no_action auto_accepted krn:asset:pcp_01
1 no_action auto_accepted krn:asset:pcp_01
2 speed_decrease auto_accepted krn:asset:pcp_01
3 no_action auto_accepted krn:asset:pcp_01
4 no_action auto_accepted krn:asset:pcp_01