コード例 #1
0
    def post(self):
        try:
            validate_res, request_args = self.validate_phonetag_sign()
            if not validate_res:
                return render_error(code=1, msg='验证签名失败')
        except Exception as e:
            logger.error('phonetag request is fail : %s' % e)
            return render_error(code=1, msg='验证签名失败')

        try:
            # 将字典转换成数据帧
            x_test = pd.DataFrame.from_dict(request_args, orient='index').T
            # 读取model文件进行过滤
            path_file_imp = os.getcwd() + "/model/phonetag_imp18122417.model"
            imp_model = joblib.load(path_file_imp)
            imp_data = imp_model.transform(x_test)
            # 读取model文件进行预测
            path_file_clf = os.getcwd() + "/model/phonetag_clf18122417.model"
            clf_model = joblib.load(path_file_clf)
            clf_data = clf_model.predict_proba(imp_data)
            # 将numpy.ndarray转list
            score = clf_data.tolist()
            return render_ok(score)
        except Exception as e:
            logger.error('phonetag request is fail : %s' % e)
            return render_error(code=2, msg='数据格式错误')
コード例 #2
0
    def post(self):
        """
        分析数据
        """
        validate_res, request_args = self.validate_applabel_sign()
        if not validate_res:
            return render_error(code=1, msg='验证签名失败')

        obj = APPLabel(request_args)
        result = obj.run()
        resCode = result.get('code', -100)
        resMsg = result.get('msg', '系统错误')
        if resCode == 0:
            return render_ok()
        return render_error(resCode, resMsg)
コード例 #3
0
    def post(self):
        validate_res, request_args = self.validate_reloanxg_sign()
        if not validate_res:
            return render_error(code=1, msg='验证签名失败')

        # 将字典的值转换成整数
        new_request_args = {}
        for key, value in request_args.items():
            new_request_args[key] = float(value)
        # logger.info("aa---\n%s" % new_request_args)

        # 读取model文件进行预测
        path_file = os.getcwd() + "/model/xgboost_fd_ending6.model"
        # logger.info("path_file---\n%s" % path_file)
        pmml_model = joblib.load(path_file)

        # 将字典转换成数据框
        x_test = pd.DataFrame.from_dict(new_request_args, orient='index').T
        # logger.info("aa---\n%s" % x_test)

        classes = pmml_model.predict_proba(x_test)
        # 将numpy.ndarray转list
        classes = classes.tolist()
        # logger.info("bbbbbb---\n%s", classes)

        resp = render_ok(classes)
        return resp
コード例 #4
0
    def post(self):
        # x_test = {
        #     'PROME_V4_SCORE':1,
        #     'multi_p2p_p_class_7':1,
        #     'loan_all':1,
        #     'history_bad_status':1,
        #     'addr_phones_nodups':1,
        #     'addr_collection_count':1,
        #     'addr_tel_count':1,
        #     'com_r_duration_mavg':1,
        #     'com_c_total_mavg':1,
        #     'com_use_time':1,
        #     'com_count':1,
        #     'com_month_answer_duration':1,
        #     'com_mobile_people':1,
        #     'com_night_duration_mavg':1,
        #     'com_max_tel_connect':1,
        #     'vs_duration_match':1,
        #     'same_phone_num':1,
        #     'shutdown_max_days':1,
        #     'advertis_weight_loss_p':1,
        #     'express_aeavy_number_p':1,
        #     'harass_weight_loss_p':1,
        #     'house_agent_aeavy_number_lable':1,
        #     'cheat_aeavy_number_sign':1,
        #     'taxi_aeavy_number_sign':1,
        #     'ring_weight_loss_sign':1
        # }
        validate_res, request_args = self.validate_xgboostr_sign()
        if not validate_res:
            return render_error(code=1, msg='验证签名失败')

        #将字典的值转换成整数
        new_request_args = {}
        for key, value in request_args.items():
            new_request_args[key] = float(value)
        #logger.info("aa---\n%s" % new_request_args)

        #读取model文件进行预测
        #path_file = os.getcwd()+"\\model\\xgboost_v_0_1_n.model"
        #path_file = os.getcwd() + "/model/xgboost_v_0_1_ok.model"
        path_file = os.getcwd() + "/model/xgboost_v_0_1_t7.model"
        #logger.info("path_file---\n%s" % path_file)
        pmml_model = joblib.load(path_file)

        #将字典转换成数据框
        x_test = pd.DataFrame.from_dict(new_request_args, orient='index').T
        #logger.info("aa---\n%s" % x_test)

        classes = pmml_model.predict_proba(x_test)
        #将numpy.ndarray转list
        classes = classes.tolist()
        #logger.info("aaa---\n%s", classes)

        resp = render_ok(classes)
        return resp
コード例 #5
0
    def post(self):
        """
        分析数据
        """
        validate_res, request_args = self.operator_sign()
        if not validate_res:
            return render_error(code=1, msg='验证签名失败')

        # 1. 分析后的数据
        obj = OperatorLogic(request_args)
        dict_data = obj.run()
        if dict_data is None:
            return render_error(code=1001, msg='写入请求表失败')

        data = {
            'credit_id': obj.credit_id,
            'base_id': obj.base_id,
            'aid': obj.aid,
            'data': dict_data
        }
        resp = render_ok(data)
        return resp
コード例 #6
0
    def post(self):
        """
        分析数据
        """
        validate_res, request_args = self.validate_sign()
        if not validate_res:
            return render_error(code=1, msg='验证签名失败')
        # 1. 分析后的数据
        obj = PodloanAnalysis(request_args)
        dict_data = obj.run()

        # 2. 保存到数据库中
        oAfDbAgent = AfDbAgent()
        res = oAfDbAgent.import_db(dict_data)
        logger.info("request_id:%s aid:%s import db result %s" %
                    (obj.request_id, obj.aid, res))
        data = {
            'request_id': obj.request_id,
            'base_id': obj.base_id,
            'aid': obj.aid,
        }
        resp = render_ok(data)
        return resp