Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Merge pull request #24 from refuel-ai/explain_docs
Browse files Browse the repository at this point in the history
Add application explanation docs
  • Loading branch information
nihit authored Feb 16, 2024
2 parents af82a28 + 5d642d9 commit 864fb09
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions docs/python-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ inputs = [
{'col_1': 'value_1', 'col_2': 'value_2' ...},
]

response = refuel_client.label(application='<APPLICATION NAME>', inputs=inputs)
response = refuel_client.label(application='<APPLICATION NAME>', inputs=inputs, explain=False)
```

Each element in `inputs` is a dictionary, with keys as names of the input columns defined in the task. For example, let's consider an application for sentiment classification called `my_sentiment_classifier`, with two input fields - `source` and `text`. You can use it as follows:
Expand Down Expand Up @@ -398,22 +398,32 @@ response = refuel_client.label(application='my_sentiment_classifier', inputs=inp
'refuel_fields':
{
'sentiment': {
'label': 'positive,
'label': ['positive'],
'confidence': 0.9758
}
}
}]
}
```

You can also set the optional `explain` parameter to `True` to get an explanation for why the provided label was returned. The explanation will be returned in the `explanation` field in the response, along with the `label` and `confidence`:

```
'sentiment': {
'label': ['positive'],
'confidence': 0.9758,
'explanation': 'The model predicted a positive sentiment because the text contains positive words like "liked" and "good".'
}
```


### Share feedback for application outputs

The SDK allows users to log feedback for online predictions. When logging predictions, it is important to identify the input request for which you're logging feedback using `refuel_uuid` from the response above:

```python

label = {'sentiment': 'negative'}
label = {'sentiment': ['negative']}
refuel_client.feedback(application='my_sentiment_classifier', refuel_uuid='...', label=label)
```

Expand Down

0 comments on commit 864fb09

Please sign in to comment.