Пример #1
0
def total_spent():
    data = [
        'customer_id,time,total_spent',
        '0,2019-01-01 08:00:00,9',
        '0,2019-01-01 08:30:00,8',
        '1,2019-01-01 09:00:00,7',
        '1,2019-01-01 09:30:00,6',
        '1,2019-01-01 10:00:00,5',
        '2,2019-01-01 10:30:00,4',
        '2,2019-01-01 11:00:00,3',
        '2,2019-01-01 11:30:00,2',
        '2,2019-01-01 12:00:00,1',
        '3,2019-01-01 12:30:00,0',
    ]

    data = read_csv(data, parse_dates=['time'])

    kwargs = {
        'data': data,
        'target_columns': ['total_spent'],
        'target_entity': 'customer_id',
        'search_settings': {
            'num_examples_per_instance': -1,
        }
    }

    label_times = LabelTimes(**kwargs)
    return label_times
Пример #2
0
def total_spent():
    label_times = {
        'data': [
            'id,customer_id,cutoff_time,total_spent',
            '0,0,2019-01-01 08:00:00,9',
            '1,0,2019-01-01 08:30:00,8',
            '2,1,2019-01-01 09:00:00,7',
            '3,1,2019-01-01 09:30:00,6',
            '4,1,2019-01-01 10:00:00,5',
            '5,2,2019-01-01 10:30:00,4',
            '6,2,2019-01-01 11:00:00,3',
            '7,2,2019-01-01 11:30:00,2',
            '8,2,2019-01-01 12:00:00,1',
            '9,3,2019-01-01 12:30:00,0',
        ],
        'settings': {
            'target_entity': 'customer_id',
            'labeling_function': 'total_spent',
            'num_examples_per_instance': -1,
        }
    }

    label_times['data'] = read_csv(
        label_times['data'],
        index_col='id',
        parse_dates=['cutoff_time'],
    )

    label_times = LabelTimes(**label_times)
    return label_times
Пример #3
0
def transactions():
    df = read_csv(data=[
        'time,amount,customer_id',
        '2019-01-01 08:00:00,1,0',
        '2019-01-01 08:30:00,1,0',
        '2019-01-01 09:00:00,1,1',
        '2019-01-01 09:30:00,1,1',
        '2019-01-01 10:00:00,1,1',
        '2019-01-01 10:30:00,1,2',
        '2019-01-01 11:00:00,1,2',
        '2019-01-01 11:30:00,1,2',
        '2019-01-01 12:00:00,1,2',
        '2019-01-01 12:30:00,1,3',
    ])
    return df
Пример #4
0
def total_spent():
    data = [
        'id,customer_id,cutoff_time,total_spent',
        '0,0,2019-01-01 08:00:00,9',
        '1,0,2019-01-01 08:30:00,8',
        '2,1,2019-01-01 09:00:00,7',
        '3,1,2019-01-01 09:30:00,6',
        '4,1,2019-01-01 10:00:00,5',
        '5,2,2019-01-01 10:30:00,4',
        '6,2,2019-01-01 11:00:00,3',
        '7,2,2019-01-01 11:30:00,2',
        '8,2,2019-01-01 12:00:00,1',
        '9,3,2019-01-01 12:30:00,0',
    ]

    data = read_csv(data, index_col='id', parse_dates=['cutoff_time'])
    lt = LabelTimes(data=data, name='total_spent', target_entity='customer_id')
    lt.settings.update({'num_examples_per_instance': -1})
    return lt