Esempio n. 1
0
    def save(self, path):
        """
        Save method allows users to save SmartPredictor object on disk using a pickle file.
        Save method can be useful: you don't have to recompile to display results later.

        Load_smartpredictor method allow to load your SmartPredictor object saved. (See example below)

        Parameters
        ----------
        path : str
            File path to store the pickle file

        Example
        --------

        >>> predictor.save('path_to_pkl/predictor.pkl')
        >>> from shapash.utils.load_smartpredictor import load_smartpredictor
        >>> predictor_load = load_smartpredictor('path_to_pkl/predictor.pkl')
        """
        dict_to_save = {}
        for att in self.__dict__.keys():
            if (isinstance(getattr(self, att),
                           (list, dict, pd.DataFrame, pd.Series, type(None)))
                    or att == "model" or att == "explainer"
                    or att == "preprocessing") and not att == "data":
                dict_to_save.update({att: getattr(self, att)})
        save_pickle(dict_to_save, path)
Esempio n. 2
0
    def save(self, path):
        """
        Save method allows user to save SmartExplainer object on disk
        using a pickle file.
        Save method can be useful: you don't have to recompile to display
        results later

        Parameters
        ----------
        path : str
            File path to store the pickle file

        Example
        --------
        >>> xpl.save('path_to_pkl/xpl.pkl')
        """
        dict_to_save = {}
        for att in self.__dict__.keys():
            if isinstance(getattr(self, att), (list, dict, pd.DataFrame, pd.Series, type(None), bool)) or att == "model":
                dict_to_save.update({att: getattr(self, att)})
        save_pickle(dict_to_save, path)