import logging


def define_problem(raw_frame):
    """
    Cleans the input, raw data and defines the set of columns that should be
    used for modeling

    :param raw_frame: the raw HMDA dataset
    :return: A dataframe clean and fit for clustering
    """

    selected_columns = [
        'applicant_income_000s',
        'loan_purpose_name',
        'hud_median_family_income',
        'loan_amount_000s',
        'originated'
    ]
    log = logging.getLogger(__name__)
    log.info("Input data size {}".format(raw_frame.shape))

    return raw_frame.assign(
        originated=lambda f: (f['action_taken'] == 1).astype('int'))\
        .loc[:, selected_columns]