Closed xesaad closed 3 years ago
Can you give an example of input / output of your prediction function?
Can you give an example of input / output of your prediction function?
Example inputs (to the wrapper function) are strings consisting of a review and an "aspect" separated by |
. For example, "this is a very comfortable chair.|comfort".
The wrapper function outputs a pair (sentiment, certainty)
of float
values, where sentiment
is a score between 0 and 1 (with 0 being negative and 1 being positive) and certainty
is a float between 0 and 1 indicating how confident the model is with this prediction.
(Under the hood, the predicton wrapper splits the string into a pair ("this is a very comfortable chair.", "comfort")
which is then passed to a model that computes the sentiment
expressed in the text towards the aspect, as well as the certainty
.)
With the wrapper function named prediction_wrapper
, I followed the tutorial and defined the following function which is used to run tests (rescaling as the sentiment
function used in the tutorial takes values between -1 and 1):
def predict_proba(inputs):
"""
Returns an array with probabilities for negative and positive.
"""
p1 = np.array([prediction_wrapper(x)[0] for x in inputs]).reshape(-1, 1)
p0 = 1- p1
return np.hstack((p0, p1))
A few test cases generated by CheckList are below.
'This is not a good screen.|design'
'This is not an exciting analysis.|value'
'This is not an awful translation.|quality'
I resolved this issue. I made an error when defining ret
: namely, I set labels="positive"
(resp. "negative"
) when should have set labels=1
(resp. 0
). This is because my model outputs a label (one of "positive"
, "negative"
or "neutral"
) and I had to modify it in order to get this prediction as a float
, but forgot to revert the labels.
Closing this issue as resolved.
Hello 👋🏼 firstly, thank you very much for making CheckList! It is very useful and well-documented.
I am receiving an
IndexError
when I try to run a test (following the tutorial on testing) using either therun
orrun_from_file
methods. As it is essentially the same traceback in either case, here is the traceback when I try to run a test from a file:If it is of use, here are some additional details: the model I am testing is an aspect-based sentiment classifier, and my test-cases are of the form
'This is not {a:pos} {mask}.|{aspect}'
whereaspect
is selected from a short list of aspects. My wrapper function for the test then splits the string at the character|
and runs the aspect-based prediction model. I can provide more details if required.The error was not raised when I ran the example in the tutorial verbatim, so I expect this is related to my wrapper function or test cases.
Environment: Python 3.7.8 CheckList installed via
pip
(so version0.0.11
)