(T)
T = 0
    folder = 'trainT-0'
T = 0
    folder = 'trainT-0'
T = 0 folder = trainT - 0
def make(T):
    """
    T = 0
    folder = 'trainT-0'
    """
    if T==-1:
        folder = 'test'
    else:
        folder = 'trainT-'+str(T)
    
    global log_
    log_ = log[log.order_number_rev>T]
    
    user_id = log_.user_id.unique()
    mp_pool = mp.Pool(total_proc)
    callback = mp_pool.map(multi, user_id)
    callback = pd.concat(callback)
    gc.collect()
    
    gr = callback.groupby('product_id')
    
    df = gr['item_1to1_cnt'].sum().to_frame()
    df.columns = ['item_1to1_cnt']
    df['item_1to1_chance'] = gr['item_1to1_chance'].sum()
    
    col = ['11to1', '10to1', '111to1', '110to1', '101to1', '100to1']
    for c in col:
        c_cnt    = 'item_{}_cnt'.format(c)
        c_chance = 'item_{}_chance'.format(c)
        df[c_cnt]    = gr[c_cnt].sum()
        df[c_chance] = gr[c_chance].sum()
    
    col = ['1to1', '11to1', '10to1', '111to1', '110to1', '101to1', '100to1']
    for c in col:
        c_cnt    = 'item_{}_cnt'.format(c)
        c_chance = 'item_{}_chance'.format(c)
        df['item_{}_ratio'.format(c)] = df[c_cnt]/df[c_chance]
    
    df.fillna(0, inplace=True)
    df.reset_index(inplace=True)
    print('writing 211 T:',T)
    df.to_pickle('../feature/{}/f211_product.p'.format(folder))
def make ( T ) : if T == - 1 : folder = 'test' else : folder = 'trainT-' + str ( T ) global log_ log_ = log [ log . order_number_rev > T ] user_id = log_ . user_id . unique ( ) mp_pool = mp . Pool ( total_proc ) callback = mp_pool . map ( multi , user_id ) callback = pd . concat ( callback ) gc . collect ( ) gr = callback . groupby ( 'product_id' ) df = gr [ 'item_1to1_cnt' ] . sum ( ) . to_frame ( ) df . columns = [ 'item_1to1_cnt' ] df [ 'item_1to1_chance' ] = gr [ 'item_1to1_chance' ] . sum ( ) col = [ '11to1' , '10to1' , '111to1' , '110to1' , '101to1' , '100to1' ] for c in col : c_cnt = 'item_{}_cnt' . format ( c ) c_chance = 'item_{}_chance' . format ( c ) df [ c_cnt ] = gr [ c_cnt ] . sum ( ) df [ c_chance ] = gr [ c_chance ] . sum ( ) col = [ '1to1' , '11to1' , '10to1' , '111to1' , '110to1' , '101to1' , '100to1' ] for c in col : c_cnt = 'item_{}_cnt' . format ( c ) c_chance = 'item_{}_chance' . format ( c ) df [ 'item_{}_ratio' . format ( c ) ] = df [ c_cnt ] / df [ c_chance ] df . fillna ( 0 , inplace = True ) df . reset_index ( inplace = True ) print ( 'writing 211 T:' , T ) df . to_pickle ( '../feature/{}/f211_product.p' . format ( folder ) )