Skip to content

TypeError: ModelAnalyzer requres eval_config argument of type tfma.EvalConfig or str. #2

Open
@PasalaJanardhan

Description

@PasalaJanardhan

Team, Getting the error "ModelAnalyzer requres eval_config argument of type tfma.EvalConfig or str." at the function check_eval_config from model_card_gen/analyze/analyzer.py. And I found the root cause at the function get_analyzers from the model_card_gen/analyze/analyzer_factory.py file. For the same, I had done the code update(replaced DFAnalyzer(dataset, eval_config) with DFAnalyzer(eval_config, dataset)) and was able to generate the model card. Please find the highlighted code below and get me an update upon reviewing. Thank You.
elif all(isinstance(ds, pd.DataFrame) for ds in datasets.values()):
# code update
# existing code
# analyzers = (DFAnalyzer(dataset, eval_config)
# for dataset in datasets.values())
# updated code
analyzers = (DFAnalyzer(eval_config, dataset)
for dataset in datasets.values())

def get_analyzers(model_path: Optional[Text] = '',
                eval_config: Union[tfma.EvalConfig, Text] = None,
                datasets:  DatasetType = None):
    """Helper function to to get colleciton of analyzer objects
    Args:
        model_path (str) : path to model
        eval_config (tfma.EvalConfig or str): representing proto file path
        data (str or pd.DataFrame): string ot tfrecord or raw dataframe containing
            prediction values and  ground truth

    Raises:
        TypeError: when eval_config is not of type tfma.EvalConfig or str
        TypeError: when data argument is not of type pd.DataFrame or str

    Returns:
        tfma.EvalResults()

    Example:
        >>> from model_card_gen.analyze import get_analyzers
        >>> get_analyzers(model_path='compas/model',
                         data='compas/eval.tfrecord',
                         eval_config='compas/eval_config.proto')
    """
    if all(isinstance(ds, TensorflowDataset) for ds in datasets.values()):
        analyzers = (TFAnalyzer(model_path, dataset, eval_config)
                     for dataset in datasets.values())
    elif all(isinstance(ds, pd.DataFrame) for ds in datasets.values()):
        # code update
        # existing code
        # analyzers = (DFAnalyzer(dataset, eval_config) 
        #              for dataset in datasets.values()) 
        # updated code
        analyzers = (DFAnalyzer(eval_config, dataset) 
                     for dataset in datasets.values())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions