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

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

Open
PasalaJanardhan opened this issue Oct 25, 2023 · 0 comments

Comments

@PasalaJanardhan
Copy link

PasalaJanardhan commented Oct 25, 2023

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())
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