
import commons, sys, os
import logging as log
import pandas as pd
import xgboost as xgb
import numpy as np
from sklearn.externals import joblib
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, f1_score, precision_score, recall_score, classification_report, confusion_matrix

def add_activations(df):
    for ind in commons.indicators:
        log.info("Adding activations for {}".format(ind))
        ind_prev = ind + "_1"
        res = df[ind].sub(df[ind_prev])
        res[res < 0] = 0
        df["act_" + ind] = res.fillna(0)
    return df

@@ -585,8 +585,390 @@
 turn df%0A
+%0Adf = df%5B~df%5B'is_test_data'%5D%5D%0Adf.drop(%5B'is_test_data'%5D, inplace=True, axis=1)%0Adf.drop(commons.indicators_ignored, inplace=True, axis=1)%0A%0Adf = add_activations(df)%0Adf.drop(commons.indicators ,inplace=True,axis=1)%0A%0A#Drop excessive months. Keep 2015-06, 2016-03/05.%0A%0Adf.drop(%5B'ncodpers', 'fecha_dato'%5D, inplace=True, axis=1)%0A%0Aactivation_columns=%5B%22act_%22 + i for i in commons.indicators%5D%0A

Update 02-02_cleanse.py