Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error application anchor #8

Open
ajayaadhikari opened this issue Apr 3, 2018 · 1 comment
Open

Error application anchor #8

ajayaadhikari opened this issue Apr 3, 2018 · 1 comment

Comments

@ajayaadhikari
Copy link

Hello,

I am trying to apply anchor on a dataset with 290 numerical features.
Following your test example I wrote the code below. But I get an error.
Could you have a look.

class_names = [0, 1]
classifier_name = "svc"
classifier_var = {"probability": True}
train, test, labels_train, labels_test = sklearn.model_selection.train_test_split(feature_vector, target_vector,
                                                                                  train_size=0.80)

classifier = src.classifiers.possible_classifiers[classifier_name](**classifier_var)
classifier.fit(train, labels_train)
print(sklearn.metrics.accuracy_score(labels_test, classifier.predict(test)))
>>> 0.825892857143

explainer = anchor_tabular.AnchorTabularExplainer(class_names, feature_names, train)
explainer.fit(train, labels_train, test, labels_test)
exp = explainer.explain_instance(test[67], classifier.predict, threshold=0.95)
>>>
C:\Users\adhikaria\PycharmProjects\SDQ\venv\lib\site-packages\anchor\anchor_base.py:58: RuntimeWarning: divide by zero encountered in log
  temp = np.log(k * n_features * (t ** alpha) / delta)
C:\Users\adhikaria\PycharmProjects\SDQ\venv\lib\site-packages\anchor\anchor_base.py:59: RuntimeWarning: invalid value encountered in log
  return temp + np.log(temp)
Traceback (most recent call last):
  File "C:/Users/adhikaria/Documents/curium/src/lime_application.py", line 142, in <module>
    exp = explainer.explain_instance(test[67], classifier.predict, threshold=0.95)
  File "C:\Users\adhikaria\PycharmProjects\SDQ\venv\lib\site-packages\anchor\anchor_tabular.py", line 281, in explain_instance
    **kwargs)
  File "C:\Users\adhikaria\PycharmProjects\SDQ\venv\lib\site-packages\anchor\anchor_base.py", line 381, in anchor_beam
    1, verbose=verbose)
  File "C:\Users\adhikaria\PycharmProjects\SDQ\venv\lib\site-packages\anchor\anchor_base.py", line 92, in lucb
    ut, lt = update_bounds(t)
  File "C:\Users\adhikaria\PycharmProjects\SDQ\venv\lib\site-packages\anchor\anchor_base.py", line 89, in update_bounds
    ut = not_J[np.argmax(ub[not_J])]
  File "C:\Users\adhikaria\PycharmProjects\SDQ\venv\lib\site-packages\numpy\core\fromnumeric.py", line 1004, in argmax
    return _wrapfunc(a, 'argmax', axis=axis, out=out)
  File "C:\Users\adhikaria\PycharmProjects\SDQ\venv\lib\site-packages\numpy\core\fromnumeric.py", line 52, in _wrapfunc
    return getattr(obj, method)(*args, **kwds)
ValueError: attempt to get argmax of an empty sequence
@marcotcr
Copy link
Owner

marcotcr commented Apr 3, 2018

Can you run the example notebooks?
Can you share an example (with data) so I can look at it in more detail?
Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants