コード例 #1
0
ファイル: SamplesBuilder.py プロジェクト: guanjunliu/OLP
    def genFeats(self, loanFieldName2Index, loans, custNum2ProtolNums, transFieldName2Index, transs, prodFieldName2Index, prods):
        '''
        为每笔贷款生成特征

        Args:
            loanFieldName2Index (dict): 贷款协议表字段索引
            loans (dict): 贷款协议表数据
            transFieldName2Index (dict): 交易流水表字段索引
            transs (dict): 交易流水表数据
            prodFieldName2Index (dict): 产品签约表字段索引
            prods (dict): 产品签约表数据

        Returns:
            dict: 特征字段索引
            list: 客户号和特征值,格式为:
                [
                  [客户号1, [特征值11, 特征值12, ...]],
                  [客户号2, [特征值21, 特征值22, ...]],
                  ...
                ]
        '''
        transFieldName2Index, transs = TransCounter((transFieldName2Index, transs)).countProp()
        prods = ProdContactCounter((prodFieldName2Index, prods), '2014/3/31').countProdContact()  # TODO
        builder = FeatureBuilder((loanFieldName2Index, loans, custNum2ProtolNums),
                             (transFieldName2Index, transs),
                             prods)
        fieldName2Index, feats = builder.buildFeature()
        feats.sort(key=lambda item: item[0])
        return fieldName2Index, feats
コード例 #2
0
ファイル: functionTest.py プロジェクト: i405817461/OLP
#tableObject = CMSBReader(config.fieldName2fieldType)
#table = tableObject.readProds(['prods.txt',])
#UniPrinter().pprint(table)
#tableFiltered = ProdContactCounter(table, config.trnFeatMonths[-1]+'/31').countProdContact()
#UniPrinter().pprint(tableFiltered)

tableObject = CMSBReader(config.fieldName2fieldType)
loanTable = tableObject.readLoans(['loan.txt','loan2.txt'])
loanCounter = LoanCounter(loanTable).countLoan()

transTable = tableObject.readTranss(['trans.txt',])
transCounter = TransCounter(transTable).countProp()

prodTable = tableObject.readProds(['prods.txt',])
prodCounter = ProdContactCounter(prodTable, config.trnFeatMonths[-1]+'/31').countProdContact()

UniPrinter().pprint(loanTable)
UniPrinter().pprint(transTable)
UniPrinter().pprint(prodTable)
print 'haha'
UniPrinter().pprint(loanCounter)
UniPrinter().pprint(transCounter)
UniPrinter().pprint(prodCounter)

fb = FeatureBuilder(loanCounter, transCounter, prodCounter)
fbResult = fb.buildFeature()
print 'hehe'
UniPrinter().pprint(fbResult)


コード例 #3
0
ファイル: functionTest.py プロジェクト: guanjunliu/OLP
#tableFiltered = ProdContactCounter(table, config.trnFeatMonths[-1]+'/31').countProdContact()
#UniPrinter().pprint(tableFiltered)

tableObject = CMSBReader(config.fieldName2fieldType)
loanTable = tableObject.readLoans(['loan.txt', 'loan2.txt'])
loanCounter = LoanCounter(loanTable).countLoan()

transTable = tableObject.readTranss([
    'trans.txt',
])
transCounter = TransCounter(transTable).countProp()

prodTable = tableObject.readProds([
    'prods.txt',
])
prodCounter = ProdContactCounter(prodTable, config.trnFeatMonths[-1] +
                                 '/31').countProdContact()

UniPrinter().pprint(loanTable)
UniPrinter().pprint(transTable)
UniPrinter().pprint(prodTable)
print 'haha'
UniPrinter().pprint(loanCounter)
UniPrinter().pprint(transCounter)
UniPrinter().pprint(prodCounter)

fb = FeatureBuilder(loanCounter, transCounter, prodCounter)
fbResult = fb.buildFeature()
print 'hehe'
UniPrinter().pprint(fbResult)