def validate_and_correct_config()

in src/responsibleai/rai_analyse/create_score_card.py [0:0]


def validate_and_correct_config(config, insight_data):
    i_data = insight_data.get_raiinsight()
    try:
        top_n = config["FeatureImportance"]["top_n"]
        if top_n > 10:
            _logger.warning(
                "Feature importance is limited to "
                "top 10 most important feature"
                f", but top_n={top_n} was specificed."
                "Setting top_n to 10 automatically."
            )
        config["FeatureImportance"]["top_n"] = 10
    except KeyError:
        pass

    if "Fairness" in config.keys():
        fc = config["Fairness"]
        cat_features = [
            f for f in fc["sensitive_features"] if f in i_data.categorical_features
        ]
        dropped_features = [
            f for f in fc["sensitive_features"] if f not in i_data.categorical_features
        ]
        _logger.warning(
            "Non categorical features dropped for fairness assessment: {}".format(dropped_features)
        )
        fc["sensitive_features"] = cat_features
    return config