(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)
        
    log_ = log[log.order_number_rev>T]
    log_['onb_max'] = log_.groupby('user_id').order_number.transform(np.max)
    
    r1_d10 = []
    r1_d2 = []
    r1_df2 = []
    r0_d10 = []
    r0_d2 = []
    r0_df2 = []
    
    seq = []
    uid_bk = pid_bk = onb_max_bk = None
    for uid,pid,onb,onb_max in tqdm(log_[['user_id', 'product_id', 'order_number', 'onb_max']].values):
        
        if uid_bk is None:
            pass
        
        elif uid==uid_bk and pid==pid_bk:
            pass
        
        elif uid!=uid_bk or pid!=pid_bk:
            r1_d10.append(conv_bi2dec(seq, onb_max_bk, True,  10))
            r1_d2.append(conv_bi2dec(seq, onb_max_bk,  True,  2))
            r1_df2.append(conv_bi2dec(seq, onb_max_bk, False, .2))
            r0_d10.append(conv_bi2dec(seq, onb_max_bk, True,  10))
            r0_d2.append(conv_bi2dec(seq, onb_max_bk,  True,  2))
            r0_df2.append(conv_bi2dec(seq, onb_max_bk, False, .2))
            seq = []
            
        seq.append(onb)
        uid_bk = uid
        pid_bk = pid
        onb_max_bk = onb_max
    
    r1_d10.append(conv_bi2dec(seq, onb_max_bk, True,  10))
    r1_d2.append(conv_bi2dec(seq, onb_max_bk,  True,  2))
    r1_df2.append(conv_bi2dec(seq, onb_max_bk, False, .2))
    r0_d10.append(conv_bi2dec(seq, onb_max_bk, True,  10))
    r0_d2.append(conv_bi2dec(seq, onb_max_bk,  True,  2))
    r0_df2.append(conv_bi2dec(seq, onb_max_bk, False, .2))
    
    df = log_[['user_id', 'product_id']].drop_duplicates(keep='first').reset_index(drop=True)
    df['seq2dec_r1_d10'] = r1_d10
    df['seq2dec_r1_d2']  = r1_d2
    df['seq2dec_r1_df2'] = r1_df2
    df['seq2dec_r0_d10'] = r0_d10
    df['seq2dec_r0_d2']  = r0_d2
    df['seq2dec_r0_df2'] = r0_df2
    
    df.to_pickle('../feature/{}/f317_user-product.p'.format(folder))
def make ( T ) : if T == - 1 : folder = 'test' else : folder = 'trainT-' + str ( T ) log_ = log [ log . order_number_rev > T ] log_ [ 'onb_max' ] = log_ . groupby ( 'user_id' ) . order_number . transform ( np . max ) r1_d10 = [ ] r1_d2 = [ ] r1_df2 = [ ] r0_d10 = [ ] r0_d2 = [ ] r0_df2 = [ ] seq = [ ] uid_bk = pid_bk = onb_max_bk = None for uid , pid , onb , onb_max in tqdm ( log_ [ [ 'user_id' , 'product_id' , 'order_number' , 'onb_max' ] ] . values ) : if uid_bk is None : pass elif uid == uid_bk and pid == pid_bk : pass elif uid != uid_bk or pid != pid_bk : r1_d10 . append ( conv_bi2dec ( seq , onb_max_bk , True , 10 ) ) r1_d2 . append ( conv_bi2dec ( seq , onb_max_bk , True , 2 ) ) r1_df2 . append ( conv_bi2dec ( seq , onb_max_bk , False , .2 ) ) r0_d10 . append ( conv_bi2dec ( seq , onb_max_bk , True , 10 ) ) r0_d2 . append ( conv_bi2dec ( seq , onb_max_bk , True , 2 ) ) r0_df2 . append ( conv_bi2dec ( seq , onb_max_bk , False , .2 ) ) seq = [ ] seq . append ( onb ) uid_bk = uid pid_bk = pid onb_max_bk = onb_max r1_d10 . append ( conv_bi2dec ( seq , onb_max_bk , True , 10 ) ) r1_d2 . append ( conv_bi2dec ( seq , onb_max_bk , True , 2 ) ) r1_df2 . append ( conv_bi2dec ( seq , onb_max_bk , False , .2 ) ) r0_d10 . append ( conv_bi2dec ( seq , onb_max_bk , True , 10 ) ) r0_d2 . append ( conv_bi2dec ( seq , onb_max_bk , True , 2 ) ) r0_df2 . append ( conv_bi2dec ( seq , onb_max_bk , False , .2 ) ) df = log_ [ [ 'user_id' , 'product_id' ] ] . drop_duplicates ( keep = 'first' ) . reset_index ( drop = True ) df [ 'seq2dec_r1_d10' ] = r1_d10 df [ 'seq2dec_r1_d2' ] = r1_d2 df [ 'seq2dec_r1_df2' ] = r1_df2 df [ 'seq2dec_r0_d10' ] = r0_d10 df [ 'seq2dec_r0_d2' ] = r0_d2 df [ 'seq2dec_r0_df2' ] = r0_df2 df . to_pickle ( '../feature/{}/f317_user-product.p' . format ( folder ) )