Commit 9c61abc3 authored by 张鹏程's avatar 张鹏程

合并 dev 分支到主分支

parents 81cfef86 c45c6138
Pipeline #902 failed with stages
This diff is collapsed.
This diff is collapsed.
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
......@@ -836,7 +836,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.0"
"version": "3.6.6"
}
},
"nbformat": 4,
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -212,7 +212,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
"version": "3.6.0"
}
},
"nbformat": 4,
......
This diff is collapsed.
......@@ -82,4 +82,28 @@ con_collection = create_engine('mysql+pymysql://rc-meta-user-pre:YqnqVfIwZFMlkGy
"""business flow 线上库"""
con_business_flow =create_engine('mysql+pymysql://real_data_test:qpRBSarm$Tv*YO!n@172.30.220.16:33314/business_flow?charset=utf8'
,echo=False)
\ No newline at end of file
,echo=False)
con_new_xyqb = create_engine('mysql+pymysql://real_data_test:qpRBSarm$Tv*YO!n@172.30.220.16:33306/xyqb?charset=utf8',echo=False)
"""vcc商户"""
con_vcc_talos = create_engine('mysql+pymysql://bigdata_test:ieneue7ldondk03d@172.30.5.27:8066/vcc_talos?charset=utf8',echo=False)
"""vcc线上库talos"""
# con_vcc_talos = create_engine('mysql+pymysql://rc_slave_user_r:fiQFWvFIQV5vn1Ai@vcc-db.quantgroups.com:3306/vcc_talos?charset=utf8',echo=False)
con_vcc_quota = create_engine('mysql+pymysql://bigdata_test:ieneue7ldondk03d@172.30.5.27:8066/vcc_quota?charset=utf8',echo=False)
"""vcc线上库quota"""
# con_vcc_quota = create_engine('mysql+pymysql://rc_feature_user:G5QcBud5eR7foGIU@172.18.4.12:3306/vcc_quota?charset=utf8',echo=False)
con_vcc_transfer = create_engine('mysql+pymysql://real_data_test:qpRBSarm$Tv*YO!n@172.30.220.16:33315/vcc_feature?charset=utf8',echo=False)
con_vcc_transfer_pay = create_engine('mysql+pymysql://real_data_test:qpRBSarm$Tv*YO!n@172.30.220.16:33316/payment_center?charset=utf8',echo=False)
con_device_info = create_engine('mysql+pymysql://pengcheng_zhang:phBnseTGbmUd7cKI@fengkong-tidb.quantgroups.com:4010/rc_user_behavior?charset=utf8'
,echo=False)
con_vcc_device_info = create_engine('mysql+pymysql://bigdata_test:ieneue7ldondk03d@172.30.5.27:8066/acsdb?charset=utf8'
,echo=False)
con_vcc_workflow = create_engine('mysql+pymysql://bigdata_test:ieneue7ldondk03d@172.30.5.27:8066/workflow?charset=utf8',echo=False)
con_vcc_score = create_engine('mysql+pymysql://bigdata_test:ieneue7ldondk03d@172.30.5.27:8066/vcc_model_score_recall?charset=utf8',echo=False)
......@@ -14,5 +14,6 @@ url_complex_order = '/features/complex_order' # 多订单
# url_collection = '/calc/loanPostFeatures' # 催收模型
url_loanPostFeatures = '/calc/loanPostFeatures' # 催收模型
url_test = '/calc/test' # 测试
url_calc_features4store = '/calc/features4store' #vcc用户商城
......@@ -174,6 +174,18 @@ class BaseFeatures():
def set_codes(self,_codes):
self.codes = _codes
def set_channel_no(self,_channel_no):
self.channel_no = _channel_no
def set_store_id(self,_store_id):
self.store_id = _store_id
def set_snapshot_time(self,_snapshot_time):
self.snapshot_time = _snapshot_time
def set_trade_no(self,_trade_no):
self.trade_no = _trade_no
def set_mapping(self,mapping):
self.mapping = mapping
......
# -*- coding:utf-8 -*-
# -*- coding:utf-8 -*-
from features.Base_Features import BaseFeatures as BF
from service.addresss_book_sql import *
import datetime
......@@ -18,11 +16,12 @@ class __INIT__(BF):
BF._apply_at = datetime.datetime.strptime(_df['apply_time'].astype(str).values[0],'%Y-%m-%d %H:%M:%S')
class 存在未结清订单数量():
"""uncompleted_loan_nums 存在未结清订单数量(还款中,在贷)"""
"""uncompleted_own_product_loan_nums 存在未结清订单数量(还款中,在贷)"""
def feature(self):
_存在未结清订单数量 = -9999999
get_quantity = quantity_ofopen_orders(self.user_id,self._apply_at)
get_quantity = quantity_ofopen_orders(self._apply_at,self.user_id)
if get_quantity.empty == False:
get_quantity_count = get_quantity['count'].values[0]
_存在未结清订单数量 = get_quantity_count
......@@ -31,7 +30,7 @@ class 存在未结清订单数量():
class 填写中申请单数量():
"""user_fill_order_nums enable = 1填写中申请单数量"""
"""user_fill_own_product_order_nums enable = 1填写中申请单数量"""
def feature(self):
_填写中申请单数量 = -9999999
get_quantity = application_forms_nums(self.uuid,self._apply_at)
......@@ -57,25 +56,10 @@ class 用户申请订单在审核中的数量():
# class 在途申请单数量():
#这个是老的特征 下面的特征进行了更改
# """apply_in_verify_num_v2 在途申请单数量(提交申请->完成放款)"""
# def feature(self):
# _在途申请单数量 = -9999999
# get_requisition_quantity_xyqb = requisition_quantity_xyqb(self.user_id,self._apply_at)
# get_requisition_quantity_business_flow = requisition_quantity_business_flow(self.uuid,self._apply_at)
# if get_requisition_quantity_xyqb.empty == False:
# get_quantity_count = get_requisition_quantity_xyqb['count_xyqb'].values[0]
# if get_requisition_quantity_business_flow.empty == False:
# get_business_flow_count = get_requisition_quantity_business_flow['count_business'].values[0]
# _在途申请单数量 = get_quantity_count + get_business_flow_count
# self._result['在途申请单数量']['value'] = _在途申请单数量
# return self._result
class 在途申请单数量():
"""apply_in_verify_num_v2 enable=1 在途申请单数量(提交申请->完成放款)"""
"""own_product_apply_in_verify_nums enable=1 在途申请单数量(提交申请->完成放款)"""
def feature(self):
_在途申请单数量 = -9999999
get_requisition_quantity_xyqb = requisition_quantity_xyqb_new(self.user_id,self._apply_at)
......
# -*- coding:utf-8 -*-
from features.Base_Features import BaseFeatures as BF
from service import Sql_contactsOperator
from service.Sql_complexOrder import *
import datetime,time
import pandas as pd
from datetime import timedelta
class __INIT__(BF):
def __init__(self):
time_now = datetime.datetime.strptime(datetime.datetime.strftime(datetime.datetime.now(),'%Y-%m-%d %H:%M:%S'),'%Y-%m-%d %H:%M:%S')
BF.df_loan_all = getSql_loanAll_v5(str(tuple([self.user_id])).replace(',)',')'))
BF._apply_at = time_now
BF.df_apply_order = pd.DataFrame()
BF.df_loan_rollBack = pd.DataFrame()
BF._df_apply = Sql_contactsOperator.getSql_userApplyQuotaRecord(str(tuple([self.user_id])).replace(',)',')'))
if BF._df_apply.empty == False:
BF._df_apply.sort_values('apply_time',inplace=True)
BF._df_apply.reset_index(drop=True,inplace=True)
if self.orderId:
BF.df_apply_order = BF._df_apply.loc[BF._df_apply['order_no'] == self.orderId]
if BF.df_apply_order.empty == False:
BF._apply_at = datetime.datetime.strptime(BF.df_apply_order['apply_time'].astype(str).values[0],'%Y-%m-%d %H:%M:%S')
if BF.df_loan_all.empty == False:
BF.df_loan_all.sort_values('apply_time',inplace=True)
BF.df_loan_all.reset_index(drop=True,inplace=True)
BF.df_loan_rollBack = get_Loan_rollBack_v5(BF.df_loan_all,BF._apply_at,passdueDay_Negative=True)
def get_loanSettleFrom(df_loan_rollBack):
"""上几笔的订单"""
df_loan_result = pd.DataFrame()
if df_loan_rollBack.empty == False:
# df_loan_rollBack = df_loan_rollBack[df_loan_rollBack["progress"] == 16]
# if df_loan_rollBack.empty == False:
df_loan_result = df_loan_rollBack[df_loan_rollBack['loan_id'] == df_loan_rollBack['loan_id'].max()]
return df_loan_result
class 历史分期中最大逾期天数可正可负():
"""delq_days_max_days_v3"""
def feature(self):
_历史分期中最大逾期天数可正可负 = -9999999
df_loan_result = self.df_loan_rollBack
if df_loan_result.empty == False:
_result =df_loan_result['passdue_day'].max()
_历史分期中最大逾期天数可正可负 = _result
self._result["历史分期中最大逾期天数可正可负"]["value"] = _历史分期中最大逾期天数可正可负
return self._result
class 订单的申请次数():
"""history_apply_cnt_v5"""
def feature(self):
_订单的申请次数 = -9999999
get_new_loan_v4_apply = new_loan_v4_apply(self.user_id,self._apply_at)['count'].values[0]
get_xiaoniu_loan_v4_apply = xiaoniu_loan_v4_apply(self.user_id,self._apply_at)['count'].values[0]
get_old_loan_v4_apply = old_loan_v4_apply(self.user_id)['count'].values[0]
_result = get_new_loan_v4_apply - get_xiaoniu_loan_v4_apply + get_old_loan_v4_apply
_订单的申请次数 = _result
self._result["订单的申请次数"]["value"] = _订单的申请次数
return self._result
class 逾期金额比率():
"""overdue_amount_ratio_v2"""
def feature(self):
_逾期金额比率 = -9999999
df_loan_result = self.df_loan_rollBack
if df_loan_result.empty == False:
df_loan_result_all = df_loan_result['monthly_repayment'].sum()
df_loan_result_passdue_day =df_loan_result[df_loan_result['passdue_day'] >0]['monthly_repayment'].sum()
_result = round(df_loan_result_passdue_day / df_loan_result_all,2)
_逾期金额比率 = _result
self._result["逾期金额比率"]["value"] = _逾期金额比率
return self._result
class 各笔订单最大的不逾期期数比():
"""overdue_days_dis_cont_ratio_v2#overdueDaysGt0DisCont 会有少许精度问题--防止四舍六入五平分"""
def feature(self):
_各笔订单最大的不逾期期数比 = -9999999
df_loan_result = self.df_loan_rollBack
sum_list = []
if df_loan_result.empty == False:
_passdue_day_list = list(set(df_loan_result[df_loan_result['passdue_day'] <= 0]['loan_id'].tolist()))
df_loan_id = df_loan_result[df_loan_result['loan_id'].isin(_passdue_day_list)]
for k,v in df_loan_id.groupby(['loan_id']):
v['term_count'] = len(v)
v['max_term'] = str(v[v['passdue_day'] >0]['term_no'].max()).replace('nan','0')
v['result'] = v['term_count'].values[0] - int(v['max_term'].values[0])
sum_list.append(v['result'].values[0])
_result = sum(sum_list) / len(df_loan_result)
_各笔订单最大的不逾期期数比 =round(_result,2)
self._result["各笔订单最大的不逾期期数比"]["value"] = _各笔订单最大的不逾期期数比
return self._result
This diff is collapsed.
This diff is collapsed.
......@@ -110,7 +110,7 @@ class 身份证是否过期():
class 测试白名单():
""" user_id_card_in_white_list 手机号归属地黑名单标志"""
""" user_id_card_in_white_list 测试白名单"""
def feature(self):
_测试白名单 = -9999999
......
......@@ -7,8 +7,6 @@ import json
import time
class __INIT__(BF):
def __init__(self):
time_now = datetime.datetime.strptime(datetime.datetime.strftime(datetime.datetime.now(),'%Y-%m-%d %H:%M:%S'),'%Y-%m-%d %H:%M:%S')
BF._created_at = time_now
......
This diff is collapsed.
# -*- coding:utf-8 -*-
from features.Base_Features import BaseFeatures as BF
from service.addresss_book_sql import *
import datetime
from service.Sql_vcc import *
import json
import time
from pandas import DataFrame
import numpy as np
import datetime
from datetime import timedelta
class __INIT__(BF):
def __init__(self):
time_now = datetime.datetime.strptime(datetime.datetime.strftime(datetime.datetime.now(),'%Y-%m-%d %H:%M:%S'),'%Y-%m-%d %H:%M:%S')
BF._apply_at = time_now
if self.orderId:
_df = getSql_Apply_quota_record(self.user_id,self.orderId)
if _df.empty == False:
BF._apply_at = datetime.datetime.strptime(_df['apply_time'].astype(str).values[0],'%Y-%m-%d %H:%M:%S')
class 惠金所9当日放款额():
""""""
def feature(self):
_惠金所9当日放款额 = 0
get_gratia_payment_amount = gratia_payment_amount()
if get_gratia_payment_amount['amount'].values[0] != None:
# get_amount_of_merchant["now_time"] = self._apply_at
# id_resufe_from['apply_time'] = id_resufe_from['apply_time'].dt.date
# get_amount_merchant_result =
_惠金所9当日放款额 = get_gratia_payment_amount['amount'].values[0]
self._result['惠金所9当日放款额']['value'] = _惠金所9当日放款额
return self._result
# class 商户当日累计交易金额():
# """last_apply_time#lastApplyRefusedRecords 同一身份证用户上次申请拒绝距今天数"""
# def feature(self):
# _商户当日累计交易金额 = -9999999
# get_amount_of_merchant = amount_of_merchant(self.store_id,self.today,self.tomorrow)
# if get_amount_of_merchant.empty == False:
# # get_amount_of_merchant["now_time"] = self._apply_at
# # id_resufe_from['apply_time'] = id_resufe_from['apply_time'].dt.date
# get_amount_merchant_result =get_amount_of_merchant['amount'].sum()
# _商户当日累计交易金额 = get_amount_merchant_result
# self._result['商户当日累计交易金额']['value'] = _商户当日累计交易金额
# return self._result
\ No newline at end of file
# -*- coding:utf-8 -*-
from features.Base_Features import BaseFeatures as BF
from service.addresss_book_sql import *
import datetime
from service.Sql_cheat import *
import re
class __INIT__(BF):
def __init__(self):
time_now = datetime.datetime.strptime(datetime.datetime.strftime(datetime.datetime.now(),'%Y-%m-%d %H:%M:%S'),'%Y-%m-%d %H:%M:%S')
BF._apply_at = time_now
if self.orderId:
_df = getSql_Apply_quota_record(self.user_id,self.orderId)
if _df.empty == False:
BF._apply_at = datetime.datetime.strptime(_df['apply_time'].astype(str).values[0],'%Y-%m-%d %H:%M:%S')
class 新老客户标签():
"""新老客户标签 hfax_user_is_new"""
def feature(self):
_新老客户标签 = -9999999
get_apply_type_value = get_apply_type(self.uuid,self.orderId)
if get_apply_type_value ==0:
_新老客户标签 = 1
else:
_新老客户标签 = 0
self._result['新老客户标签']['value'] = _新老客户标签
return self._result
class 客户渠道来源标签():
"""客户渠道来源标签 hfax_user_apply_from#mappingCode"""
def feature(self):
_客户渠道来源标签 = -9999999
mapp_apply = {"渠道编号": [1, 195, 198, 214, 217, 263, 333, 445, 159407,
159561, 159583, 159731, 159753, 159843, 159845,
159849, 159860, 159861, 159862, 159881],
"对应渠道号": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]}
if self.orderId:
get_apply_type = chose_apply_from(self.orderId)
if get_apply_type.empty ==False:
mapp_df = pd.DataFrame(mapp_apply)
get_apply_type_value = mapp_df[mapp_df['渠道编号']==get_apply_type['apply_from'].values[0]]
if get_apply_type_value.empty == True:
_客户渠道来源标签 = -9999999
else:
_客户渠道来源标签 = get_apply_type_value['对应渠道号'].values[0]
self._result['客户渠道来源标签']['value'] = _客户渠道来源标签
return self._result
class 用户来源():
"""用户来源 hfax_user_apply_from#channelsSource"""
def feature(self):
_用户来源 = -9999999
inner_applyfrom = [198,1,217,214]
else_list = [1, 195, 198, 214, 217, 263, 333, 445, 159407,
159561, 159583, 159731, 159753, 159843, 159845,
159849, 159860, 159861, 159862, 159881]
if self.orderId:
get_apply_type = chose_apply_from(self.orderId)
if get_apply_type.empty ==False:
if get_apply_type['apply_from'].values[0] in else_list:
if get_apply_type['apply_from'].values[0] in inner_applyfrom:
_用户来源 = 1
else:
_用户来源 = 2
else:
_用户来源 = -9999999
self._result['用户来源']['value'] = _用户来源
return self._result
\ No newline at end of file
# -*- coding:utf-8 -*-
from features.Base_Features import BaseFeatures as BF
from service.addresss_book_sql import *
import datetime
from service.Sql_vcc import *
import json
import time
from pandas import DataFrame
import numpy as np
import datetime
from datetime import timedelta
class __INIT__(BF):
def __init__(self):
time_now = datetime.datetime.strptime(datetime.datetime.strftime(datetime.datetime.now(),'%Y-%m-%d %H:%M:%S'),'%Y-%m-%d %H:%M:%S')
BF._apply_at = time_now
if self.orderId:
_df = getSql_Apply_quota_record(self.user_id,self.orderId)
if _df.empty == False:
BF._apply_at = datetime.datetime.strptime(_df['apply_time'].astype(str).values[0],'%Y-%m-%d %H:%M:%S')
class 用户身份证是否过期():
"""user_ocr_info#isValid 身份证是否过期 需求待修改"""
def feature(self):
_用户身份证是否过期 = -9999999
id_time= int(str(self._apply_at).split()[0].replace("-", ""))
card_expires_time = card_expires(self.uuid, self.orderId)
if isinstance(card_expires_time,int):
if id_time >= card_expires_time:
_用户身份证是否过期 = 0
elif id_time < card_expires_time:
_用户身份证是否过期 = 1
self._result['用户身份证是否过期']['value'] = _用户身份证是否过期
return self._result
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment