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

issue with the predict function, classifier problem, categorical dataset #11

Closed
skavula opened this issue Apr 13, 2018 · 5 comments
Closed

Comments

@skavula
Copy link

skavula commented Apr 13, 2018

Hi, I found the paper on anchor extremely interesting. The dataset I have only has categorical features with values 0 and 1. I tested it for different models but the code, throws an error in the line, classifier_fn(self.encoder.transform(x)) . As the feature vectors that the dataset has are already discretized, anchor discretizes it further, irrespective of the input throwing an error from the predict function. Could you please help me with the issue. Thanks.

@marcotcr
Copy link
Owner

Sorry for the delay in responding. Are you using the categorical_features parameter with all of your features when initializing the explainer?

If so, can you please share your code?

@skavula
Copy link
Author

skavula commented May 1, 2018

No problem. I am using the categorical_features parameter with all the features in the dataset.
The dataset has categorical features only. These features when fed to the model are discretized by anchor, and this doubles the number of feature vectors (the original 51 feature vectors are converted into 102 feature vectors).
screen shot 2018-05-01 at 10 27 38 am

clf is a one class SVM model.
exp = explainer.explain_instance(test_data[idx], clf.predict, threshold=0.95)

The error it throws is :
return classifier_fn(self.encoder.transform(x))

ValueError: cannot use sparse input in 'OneClassSVM' trained on dense data

Thank you.

@marcotcr
Copy link
Owner

I guess I responded to this via email and forgot the thread

@skavula
Copy link
Author

skavula commented May 24, 2018 via email

@marcotcr
Copy link
Owner

marcotcr commented May 25, 2018

how about this, try encapsulating the SVM function:

def predict_fn(data):
  return clf.predict(data.todense())

And use this in explain_instance

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