"""
It usually takes about 29,180 seconds (8 hours).
"""

import os
import math
import copy
import cPickle as pickle
import numpy as np
from data import model
from sklearn import mixture

def discretize_elems_in_list(df, l, key):
    """
    It converts categorical values to integer values, so you need to care 
    when you use this function.
    """

    for i, _ in enumerate(l):
        df[key][df[key]==l[i]]=i
    return df

def scale_bignums_to_log2(df,targets):
    for i in range(len(targets)):
        for j in range(df.shape[0]):
                df[targets[i]].iloc[j]=int(math.log(1+df[targets[i]].iloc[j],2))
    df.iloc[0]
    return df

def discretize_elems(df, attacks):
    protocols = list(set(df['protocol_type']))
    services = list(set(df['service']))
    flags = list(set(df['flag']))