小花培训笔记

同一个ip过去的登录次数

re=login_table.groupby(['ip'])['event_id'].apply(lambda x:len(np.unique(x))).reset_index()
re1=login_table[['cid','ip']].drop_duplicates()
ip_login_count_data=pd.merge(re1,re,on=['ip'],how='left')

合并数据

login_merge_columns=[pipd,id_count,ip_login_count,country_account,platform_channel,mobile_count,mobilecity_login_account]
login_features=pd.DataFrame(login_table['cid'].unique(),columns=['cid'])
#print(login_features.shape[0])
for i in login_merge_columns:
    login_features=pd.merge(login_features,i,on=['cid'],how='left')
print(login_features.shape[0])

同一个cid每次贷款金额的均值 Loan_mean

def calcute(columns,func,name):
    we=loan_table.groupby(['cid'])[columns].agg(func).reset_index()
    we1=we.rename(columns={columns:name})
    return we1
Loan_mean=calcute('loanAmount','mean','Loan_mean')
	cid						Loan_mean
0	20170801000012728075	9468.000
1	20170801000012728093	8876.250

计算KS值的标准代码

from scipy.stats import ks_2samp
get_ks = lambda y_pred,y_true: ks_2samp(y_pred[y_true==1], y_pred[y_true!=1]).statistic
get_ks(x,y)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值