Git Product home page Git Product logo

Comments (6)

oegedijk avatar oegedijk commented on May 13, 2024 1

released the bug fix, so if you pip install -U explainerdashboard then it should also work now without the patch.

from explainerdashboard.

oegedijk avatar oegedijk commented on May 13, 2024

Do you have the code that generated this error?

Just added the plot vs feature component in the latest release so could be that there are still bugs...

from explainerdashboard.

hkoppen avatar hkoppen commented on May 13, 2024
explainer = RegressionExplainer(model, X, y)

ExplainerDashboard(explainer,
                   importances=True,
                   model_summary=True,
                   contributions=True,
                   whatif=True,
                   shap_dependence=True,
                   shap_interaction=False,
                   decision_trees=False
                   
    ).run()

where X is an dataframe of shape (1000, 37) and y a series with according target values.

from explainerdashboard.

oegedijk avatar oegedijk commented on May 13, 2024

Hmm, without seeing the data on which it breaks it is a little bit hard to debug, so could you try a few things?

  1. Does it work with the built-in titanic datasets from the examples? If not it's something about your system, if it does then there's probably something different about your dataset.

  2. Could you check that the indexes for the X and y match? (they should automatically be made to match, but good to check)

    assert np.all(explainer.X.index == explainer.y.index)
  3. Do you get the same bug when you run

    explainer.plot_residuals_vs_feature("Age")

    ?

  4. In case it still fails, could you try monkeypatching this fix and see if it helps?

import types
from explainerdashboard.explainer_plots import plotly_residuals_vs_col

def plot_residuals_vs_feature2(self, col, residuals='difference', round=2, 
                dropna=True, points=True, winsor=0):
        """Plot residuals vs individual features

        Args:
          col(str): Plot against feature col
          residuals (str, {'difference', 'ratio', 'log-ratio'} optional): 
                    How to calcualte residuals. Defaults to 'difference'.
          round(int, optional): rounding to perform on residuals, defaults to 2
          dropna(bool, optional): drop missing values from plot, defaults to True.
          points (bool, optional): display point cloud next to violin plot. 
                    Defaults to True.
          winsor (int, 0-50, optional): percentage of outliers to winsor out of 
                    the y-axis. Defaults to 0.

        Returns:
          plotly fig
        """
        if self.y_missing:
            raise ValueError("No y was passed to explainer, so cannot plot residuals!")
        assert col in self.columns or col in self.columns_cats, \
            f'{col} not in columns or columns_cats!'
        col_vals = self.X_cats[col] if self.check_cats(col) else self.X[col]
        na_mask = col_vals != self.na_fill if dropna else pd.Series(np.array([True]*len(col_vals)), index=self.X.index) 
        return plotly_residuals_vs_col(
            self.y[na_mask], self.preds[na_mask], col_vals[na_mask], 
            residuals=residuals, idxs=self.idxs.values[na_mask], points=points, 
            round=round, winsor=winsor, index_name=self.index_name)
    
explainer.plot_residuals_vs_feature2 = types.MethodType(plot_residuals_vs_feature2, explainer)
explainer.plot_residuals_vs_feature2("Age")

from explainerdashboard.

oegedijk avatar oegedijk commented on May 13, 2024

Wait! Found it! The bug is with dataframes that have a RangeIndex. (the test datasets all have str indexes, so bug didn't show up in the tests).

For now here's the patch:

X.index = X.index.astype(str)
explainer = RegressionExplainer(model, X, y)

ExplainerDashboard(explainer,
                   importances=True,
                   model_summary=True,
                   contributions=True,
                   whatif=True,
                   shap_dependence=True,
                   shap_interaction=False,
                   decision_trees=False
                   
    ).run()

Will release a new version soon that fixes this bug.

Thanks for finding it and pointing it out!

from explainerdashboard.

hkoppen avatar hkoppen commented on May 13, 2024

Nice catch, works perfectly now!

from explainerdashboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.