1
$\begingroup$
exp = explainer.explain_instance(df_val_final.Description[idx],predproba_list,num_features=5, top_labels=2)

While executing the explain instance of LimeTextExplainer, the above statement keeps on executing continuously with the below warning message. Execution stops only if I interrupt the kernel

C:\ProgramData\Anaconda3\lib\site-packages\fastai\torch_core.py:83: UserWarning: Tensor is int32: upgrading to int64; for better performance use int64 input
  warn('Tensor is int32: upgrading to int64; for better performance use int64 input')
C:\ProgramData\Anaconda3\lib\site-packages\fastai\torch_core.py:83: UserWarning: Tensor is int32: upgrading to int64; for better performance use int64 input
 warn('Tensor is int32: upgrading to int64; for better performance use int64 input')
C:\ProgramData\Anaconda3\lib\site-packages\fastai\torch_core.py:83: UserWarning: Tensor is int32: upgrading to int64; for better performance use int64 input
  warn('Tensor is int32: upgrading to int64; for better performance use int64 input')

I want to use my own custom classifier model and hence I wrote a classifier function - predproba_list, which returns a numpy array of predicted probabilities for the classes Below is the function code

def predproba_list(test1) :
    pred = learn_clf.predict(test1)
    return np.array(pred[2])
    

pred[2] vaue is tensor([0.1423, 0.2133, 0.6444]) which i then convert to a numpy array

Can you please advise if the return value of the function is as expected by the explain instance's classifier function, and what could be causing the code to keep on executing without any result?

$\endgroup$
1
  • $\begingroup$ Now I am getting the below error : ValueError: Found input variables with inconsistent numbers of samples: [5000, 1]. 5000 is the default value for argument num_samples in function explain_instance() if it is not explicitly defined. How is the value for num_samples determined if need to set it explicitly $\endgroup$
    – Mayur
    Commented May 6, 2021 at 13:02

1 Answer 1

0
$\begingroup$

I am also struggling with the LimeTextExplainer and stumbled over your question. The return value of your predproba_list should be an array of arrays of floats. e.g.:

predproba_list('a') 

return:
array([[0.07965168, 0.07578776, 0.2927914 , 0.06609259, 0.03115178]])

I hope this helps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.