示例#1
0
    def extract(self):
        self.init()

        begin_time = time.time()
        resmap = {}
        for idl in self.m_fid_list:
            idl = int(idl)
            if idl in self.m_feature_map:
                time1 = time.time()
                try:
                    value = self.m_feature_map[idl]()

                    resmap[int(idl)] = str(value)
                except:
                    logger.error(
                        "%s=%s,fid=%d\n错误信息为[%s]" %
                        (self.m_key, self.m_value, idl, get_tb_info()))
                    resmap[int(idl)] = "-9999"
                time2 = time.time()
                logger.debug("%s=%s,fid=%d,cost=%f秒" %
                             (self.m_key, self.m_value, idl, time2 - time1))
        end_time = time.time()
        logger.info(
            "%s=%s,%s特征,cost=%f秒" %
            (self.m_key, self.m_value, self.m_flag, end_time - begin_time))
        return resmap
示例#2
0
def get_sms_data(_key="user_id",_value=None,_end_time=None):
    msg  = "success"    ##程序正常时返回success,否则返回错误信息;
    flag = 0            ##程序正常时返回0,否则返回-1;
    dst  = None         ##程序正常时返回结果,否则返回None;

    try:
        path_sms = os.path.join(ROOT_DIR,"data/sms.csv") 
        data_df  = pandas.read_csv(path_sms)
        dst      = data_df[data_df[_key] == _value]
        logger.info("%s=%s,get_sms_data完成" % (_key,_value))
    except:
        logger.error("%s=%s,get_sms_data失败" % (_key,_value))
        msg  = get_tb_info()
        flag = -1
        dst  = None
    return msg,flag,dst
示例#3
0
def get_credit_time(_key="user_id",_value=None):
    msg  = "success"    ##程序正常时返回success,否则返回错误信息;
    flag = 0            ##程序正常时返回0,否则返回-1;
    dst  = None         ##程序正常时返回结果,否则返回None;
    con  = Connect_db()

    if True:
        print("enter get_credit_time::")
        print("读取本地文件的尚未完成","unfix")
    try:
        dst  = con.con_mysql("dbaaa", "select credit_time from tableaaa where id = (%s)" % _value)
        dst  = int(dst.iloc[0]["credit_time"])
        logger.info("%s=%s,get_credit_time完成" % (_key,_value))
    except:
        logger.error("%s=%s,get_credit_time失败" % (_key,_value))
        msg  = get_tb_info()
        flag = -1
        dst  = None
    return msg,flag,dst
示例#4
0
from utils.local_config import logger  ## 打印日志的全局变量,从log.conf中解析
from utils.local_config import feaconf  ## 特征配置的全局变量,从feature.conf中解析
from utils.data_api import get_credit_time  ## 获取授信时间

from fdmutils.common import get_tb_info  ## 异常处理
from fdmutils.common import debug_line  ## 打印空行,屏幕输出间隔开,方便调试

##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
## 参数设置(日志|特征)
## 选取一个用户测试
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
key = "user_id"
value = "id001"

begin_time = time.time()
logger.info("%s=%s,begin" % (key, value))

##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
## 特征提取类,初始化为对象
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
feature_obj = CFeatureExtractObj()
feature_obj.init()

##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
## 获取授信时间:
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
##msg,flag,credit_time = get_credit_time(_key=key,_value=value)
##print("credit_time==",credit_time,type(credit_time))
credit_time = None

##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,