Exemplo n.º 1
0
    def inspect(self, filename=None) -> Dict[str, str]:
        """
        Get all details of the pipeline in human-readable format.

        For a shorter human-readable representation, use MatPipe.summarize().

        Args:
            filename (str): An optional  '.txt', '.yaml', '.yml', or '.json'
                filename to use for saving the pipeline inspect.

        Returns:
            (dict): A dict of strings in human readable format. Contains a
                string representation of every object and user parameter.
        """
        attrs = return_attrs_recursively(self)
        if filename:
            save_dict_to_file(attrs, filename)
        return attrs
Exemplo n.º 2
0
    def summarize(self, filename=None) -> Dict[str, str]:
        """
        Get an executive summary of the most important parts of the pipeline.
        Useful for understanding the pipeline at a high level.

        For a more detailed human-readable representation, use MatPipe.inspect.

        Args:
            filename (str): An optional  '.txt', '.yaml', '.yml', or '.json'
                filename to use for saving the pipeline summarize.

        Returns:
            (dict): A dict of strings in human readable format. Contains a
                string representation of every object and user parameter.
        """
        cleaner_attrs = [
            "encoder",
            "feature_na_method",
            "na_method_fit",
            "na_method_transform",
            "drop_na_targets",
        ]
        cleaner_data = {
            attr: str(getattr(self.cleaner, attr))
            for attr in cleaner_attrs
        }

        reducer_attrs = ["reducers", "reducer_params"]
        reducer_data = {
            attr: str(getattr(self.reducer, attr))
            for attr in reducer_attrs
        }

        attrs = {
            "featurizers": self.autofeaturizer.featurizers,
            "ml_model": str(self.learner.best_pipeline),
            "feature_reduction": reducer_data,
            "data_cleaning": cleaner_data,
            "features": self.learner.features,
        }
        if filename:
            save_dict_to_file(attrs, filename)
        return attrs
Exemplo n.º 3
0
 def test_save_dict_to_file(self):
     test_dict = {"a": "A", "b": 1, "c": [1, "q"], "d": {"m": [3, 4]}}
     for ext in AMM_SUPPORTED_EXTS:
         filename = self._get_remnant_path(ext)
         save_dict_to_file(test_dict, filename=filename)
         self.assertTrue(os.path.isfile(filename))