Exemple #1
0
    def __init__(self, logging=True):
        self.dataset = None
        self.session = None
        self.header = None
        self.isSess = False

        if logging:
            self.log = open('./log/' + date() + '.log', 'a')
        else:
            self.log = None
Exemple #2
0
    def __init__(self, split=0.7, logging=True, random_state=None):
        self.dataset = None
        self.session = None
        self.train_dataset = None
        self.test_dataset = None
        self.train_session = None
        self.test_session = None

        self.flows = None
        self.train_flows = None
        self.test_flows = None

        self.split_ratio = split
        self.train_size = None
        self.seed = random_state
        self.skip_datas = []

        use_cores = multiprocessing.cpu_count() // 3 * 2

        self.pclf = RandomForestClassifier(n_jobs=use_cores,
                                           random_state=random_state)
        self.sclf = RandomForestClassifier(n_jobs=use_cores,
                                           random_state=random_state)
        self.le = LabelEncoder()
        self.pscaler = MinMaxScaler()
        self.sscaler = MinMaxScaler()

        self.spreds_train = None
        self.spreds_test = None
        self.sprobs_train = None
        self.sprobs_train_all = None
        self.sprobs_test = None
        self.sprobs_test_all = None

        self.ppreds_train = None
        self.ppreds_test = None
        self.pprobs_train = None
        self.pprobs_train_all = None
        self.pprobs_test = None
        self.pprobs_test_all = None

        self.pkt_train_ptime_mean = None
        self.pkt_test_ptime_mean = None

        if logging:
            self.log = open('/tf/md0/thkim/log/' + date() + '.log', 'a')
        else:
            self.log = None
Exemple #3
0
    def __init__(self, h_threshold=1.0, random_state=None, verbose=True):
        self.ppreds = None
        self.pprobs = None
        self.spreds = None
        self.sprobs = None
        self.flows = None
        self.classes = None
        self.y_true = None
        self.h_threshold = h_threshold
        self.l_threshold = None
        self.init_th = None
        self.step = None
        self.isInit = False
        self.delta = None
        self.verbose = verbose
        np.random.seed(random_state)

        if verbose:
            self.log = open('./log/' + date() + '.log', 'a')
        else:
            self.log = None
Exemple #4
0
    def __init__(self, split=0.7, clf='rf', logging=True, random_state=None):
        self.train_dataset = None
        self.test_dataset = None

        self.split_ratio = split
        self.train_size = None
        self.seed = random_state
        self.skip_datas = []

        np.random.seed(random_state)
        use_cores = multiprocessing.cpu_count() // 4 * 3
        if clf == 'rf':
            self.sclf = RandomForestClassifier(n_jobs=use_cores,
                                               random_state=random_state)
        elif clf == 'dt':
            self.sclf = DecisionTreeClassifier(random_state=random_state)
        elif clf == 'et':
            self.sclf = ExtraTreeClassifier(random_state=random_state)
        elif clf == 'adt':
            self.sclf = AdaBoostClassifier(
                base_estimator=DecisionTreeClassifier(
                    random_state=random_state),
                random_state=random_state)
        elif clf == 'arf':
            self.sclf = AdaBoostClassifier(
                base_estimator=RandomForestClassifier(
                    n_jobs=use_cores, random_state=random_state),
                random_state=random_state)
        elif clf == 'gbt':
            self.sclf = GradientBoostingClassifier(random_state=random_state)
        self.le = LabelEncoder()
        self.scaler = MinMaxScaler()

        self.spreds_train = None
        self.spreds_test = None

        if logging:
            self.log = open('./log/' + date() + '.log', 'a')
        else:
            self.log = None
Exemple #5
0
def log_format(*args):
    strname = '[' + cktime.date() + ']'
    for arg in args[:-1]:
        strname = strname + '[' + arg + ']'
    strname = strname + args[-1] + '.log'
    return strname