def _get_variables(variables, explainer):
    """
    Get valid variables for the profile

    :param variables: collection of variables
    :param explainer: Explainer object
    :return: collection of variables
    """
    if variables:
        if not set(variables).issubset(explainer.var_names):
            raise ValueError('Invalid variable names')
    else:
        variables = explainer.var_names
    return variables