pythonscikit-learnlime

LimeTabularExplainer function from lime.lime_tabular doesn't work: ValueError: Domain error in arguments


I am trying to create LimeTabularExplainer which I remember worked earlier but doesn't now. My trials below thought would work but didn't work. Please help, thanks in advance!

I tried checking if feature_names is list or not and it is. Tried removing training_labels argument as it is mentioned not required in LIME Docs Tried using original target variable with categorical levels 'YES' and 'NO' as well as converted it to 1 and 0 respectively.

explainer = LimeTabularExplainer(training_data= final_tr.values,training_labels=yTrain,feature_names=final_tr.columns,mode='classification')```

  File "D:\Anaconda\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 938, in rvs
    raise ValueError("Domain error in arguments.")

ValueError: Domain error in arguments.

## Structure of my data: ##


> final_tr.columns : output (list):
> Index(['W_LAST_NAME_COMMONALITY_RANK', 'W_FIRST_NAME_COMMONALITY_RANK',
       'C_NM_FAMILYNAME_COMMONALITY_RANK', 'C_NM_GIVENNAME_COMMONALITY_RANK',
       'C_DA_BIRTH_DAY', 'C_AGE', 'F_AGE_BELOW_18', 'GNM_NameScore',
       'GNM_DoBScore', 'F_EXACT_FULLNAME_MATCH', 'MF_FUZZY_FULLNAME_MATCH',
       'MF_EXACT_LN_MATCH', 'MF_EXACT_FN_MATCH', 'MF_MATCH_DOB',
       'MF_MATCH_YOB', 'MF_MATCH_RESIDENCE', 'MF_MATCH_CITY',
       'MF_MATCH_NATIONALITY', 'W_CATEGORY_POLITICAL INDIVIDUAL',
       'C_CO_GENDER_M', 'C_CO_GENDER_Unknown'],
      dtype='object')
> yTrain.head()
6167      NO
7035      NO
1531      NO
4315      NO
723       NO
4329      NO
8994      NO
2498      NO
9065      NO
4735      NO
2259     YES
9808     YES
7102      NO
7274      NO

> final_tr.values
array([[  3.,  25.,   3., ...,   0.,   0.,   1.],
       [295., 594., 293., ...,   0.,   1.,   0.],
       [150., 101.,  59., ...,   0.,   1.,   0.],
       ...,
       [ 23., 594., 293., ...,   0.,   1.,   0.],
       [ 39.,  15.,  71., ...,   0.,   0.,   1.],
       [483.,   4., 487., ...,   1.,   0.,   1.]])

Expected: explainer object to be able to apply on new instance of test


Solution

  • A similar query has been raised as an issue on the github project: https://github.com/marcotcr/lime/issues/352

    There is a bug with lime version 0.1.1.35 that can cause this issue. If you have this version then update and see if this fixes the issue