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

Linear SVC model on multiclass classification #256

Open
Muhammad4997 opened this issue Mar 8, 2023 · 0 comments
Open

Linear SVC model on multiclass classification #256

Muhammad4997 opened this issue Mar 8, 2023 · 0 comments

Comments

@Muhammad4997
Copy link

I have trained a model on a multiclass dataset using tpot which returns the Linear SVC as best model with the following parameters

{'linearsvc__C': 5.0, 'linearsvc__dual': False, 'linearsvc__fit_intercept': True, 'linearsvc__intercept_scaling': 1, 'linearsvc__loss': 'squared_hinge', 'linearsvc__max_iter': 1000, 'linearsvc__multi_class': 'ovr', 'linearsvc__penalty': 'l2', 'linearsvc__tol': 0.0001, 'linearsvc__verbose': 0}

and from that I am trying to create a explainer Dashboard which is throwing the following error

"Traceback (most recent call last):
File "/numtraPlatform/numtrav3.0services/ExplainerDash.py", line 129, in dashboardfun
external_stylesheets=[Constants.explainer_stylesheet])
File "/anaconda/envs/env_37/lib/python3.7/site-packages/explainerdashboard/dashboards.py", line 587, in init
fluid=fluid))
File "/anaconda/envs/env_37/lib/python3.7/site-packages/explainerdashboard/dashboards.py", line 90, in init
self.tabs = [instantiate_component(tab, explainer, name=str(i+1), **kwargs) for i, tab in enumerate(tabs)]
File "/anaconda/envs/env_37/lib/python3.7/site-packages/explainerdashboard/dashboards.py", line 90, in
self.tabs = [instantiate_component(tab, explainer, name=str(i+1), **kwargs) for i, tab in enumerate(tabs)]
File "/anaconda/envs/env_37/lib/python3.7/site-packages/explainerdashboard/dashboard_methods.py", line 688, in instantiate_component
component = component(explainer, name=name, **kwargs)
File "/anaconda/envs/env_37/lib/python3.7/site-packages/explainerdashboard/dashboard_components/composites.py", line 334, in init
hide_selector=hide_selector, **kwargs)
File "/anaconda/envs/env_37/lib/python3.7/site-packages/explainerdashboard/dashboard_components/overview_components.py", line 421, in init
self.col = self.explainer.columns_ranked_by_shap()[0]
File "/anaconda/envs/env_37/lib/python3.7/site-packages/explainerdashboard/explainers.py", line 66, in inner
return func(self, **kwargs)
File "/anaconda/envs/env_37/lib/python3.7/site-packages/explainerdashboard/explainers.py", line 1043, in columns_ranked_by_shap
return self.mean_abs_shap_df(pos_label).Feature.tolist()
File "/anaconda/envs/env_37/lib/python3.7/site-packages/explainerdashboard/explainers.py", line 66, in inner
return func(self, **kwargs)
File "/anaconda/envs/env_37/lib/python3.7/site-packages/explainerdashboard/explainers.py", line 2421, in mean_abs_shap_df
_ = self.get_shap_values_df()
File "/anaconda/envs/env_37/lib/python3.7/site-packages/explainerdashboard/explainers.py", line 66, in inner
return func(self, **kwargs)
File "/anaconda/envs/env_37/lib/python3.7/site-packages/explainerdashboard/explainers.py", line 2290, in get_shap_values_df
(f"len(self.label)={len(self.labels)}, but "
AssertionError: len(self.label)=3, but shap returned shap values for 2 classes! Adjust the labels parameter accordingly!

I am trying to generate dashboard something like

def predict_proba(self, X):
pred = self.predict(X)
return np.array([1 - pred, pred]).T
model.predict_proba = types.MethodType(predict_proba, model)
explainer = ClassifierExplainer(model, df[cols], df[label], shap='kernel')
dash = ExplainerDashboard(explainer, name=runID, title=dashtitle, hide_poweredby=True,
external_stylesheets=[Constants.explainer_stylesheet])

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

1 participant