Пример #1
0
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 21 12:00:25 2018

@author: Franc
"""

import numpy as np

from steppy.base import BaseTransformer
from steppy.utils import get_logger

logger = get_logger()


class CreditFeature(BaseTransformer):
    """cat_feature, num_feature待补充"""
    def __init__(self, **kwargs):
        self.data = None
        self.cat_feature = []
        self.num_feature = []
        self.na_value = np.nan
        self.na_fill = 0

    def transform(self, df):
        df = df.sort_values(['SK_ID_CURR', 'SK_ID_PREV', 'MONTHS_BALANCE'])
        df.loc[df['AMT_DRAWINGS_ATM_CURRENT'] < 0,
               'AMT_DRAWINGS_ATM_CURRENT'] = np.nan
        df.loc[df['AMT_DRAWINGS_CURRENT'] < 0, 'AMT_DRAWINGS_CURRENT'] = np.nan
        # cat_feature
        df['NAME_CONTRACT_IS_COMPLETED'] = \
import gc

import numpy as np
from deepsense import neptune
from sklearn.externals import joblib
from steppy.base import BaseTransformer
from steppy.utils import get_logger

from .utils import set_seed

logger = get_logger()


class RandomSearchOptimizer(BaseTransformer):
    def __init__(self,
                 TransformerClass,
                 params,
                 score_func,
                 maximize,
                 train_input_keys,
                 valid_input_keys,
                 n_runs,
                 callbacks=None):
        super().__init__()
        self.TransformerClass = TransformerClass
        self.param_space = create_param_space(params, n_runs)

        # keys 标记的是传入数据键值对的键值
        self.train_input_keys = train_input_keys
        self.valid_input_keys = valid_input_keys