import tensorflow as tf
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.neural_network import MLPClassifier

from log_data.loader import LogDataLoader
from log_data.processor import Preprocessor, split_data, separate_features_and_label
from models.sklearn import SklearnHelper
from printers.plt import print_confusion_matrix

FLAGS = tf.app.flags.FLAGS
tf.app.flags.DEFINE_integer('date', 10,
                            """테스트에 사용할 날짜""")

if __name__ == '__main__':
    loader = LogDataLoader()
    batch = loader.load_batch(FLAGS.date)
    batch = Preprocessor.process(batch)
    train_data, validate_data, test_data = split_data(batch, validation_rate=0)

    rf = SklearnHelper(cls=MLPClassifier, params={
        'warm_start': True,
        'hidden_layer_sizes': (100,)
    })

    x_train, y_train = separate_features_and_label(train_data)
    rf.train(x_train, y_train)

    predicted_labels = rf.predict(test_data.drop('pay', axis=1))
    print_confusion_matrix(test_data.pay.apply(lambda pay: 1 if pay > 0 else 0), predicted_labels)

@@ -228,16 +228,57 @@
 assifier
+%0Afrom imblearn.over_sampling import SMOTE
 %0A%0Afrom l
@@ -821,16 +821,147 @@
 rate=0)%0A
+    x_train, y_train = separate_features_and_label(train_data)%0A%0A    sm = SMOTE()%0A    x_res, y_res = sm.fit_sample(x_train, y_train)
 %0A    rf 
@@ -1071,79 +1071,19 @@
 100,
+ 100
 )%0A    %7D
-)%0A%0A    x_train, y_train = separate_features_and_label(train_data
 )%0A  
@@ -1095,30 +1095,26 @@
 train(x_
-train, y_train
+res, y_res
 )%0A%0A    p

test using SMOTE(oversampling)