# Path: src/main/config.py
# TRAIN_SPLIT_FILE = os.path.join('data','classification_data','training_split.csv')
# TEST_SPLIT_FILE = os.path.join('data','classification_data','test_split.csv')
# VAL_SPLIT_FILE = os.path.join('data','classification_data','dev_split.csv')
# D_ND_DIR = os.path.join('data','disc_nondisc')
# POS_NEG_DIR = os.path.join('data','pos_neg')
# SEL_FEAT_TRAIN_REGULAR_CLASSIFY = os.path.join('data','selected_features','regular','classify','train')
# SEL_FEAT_TEST_REGULAR_CLASSIFY = os.path.join('data','selected_features','regular','classify','test')
# SEL_FEAT_VAL_REGULAR_CLASSIFY = os.path.join('data','selected_features','regular','classify','val')
# SEL_FEAT_TRAIN_REGULAR_ESTIMATE = os.path.join('data','selected_features','regular','estimate','train')
# SEL_FEAT_VAL_REGULAR_ESTIMATE = os.path.join('data','selected_features','regular','estimate','val')
# SEL_FEAT_TEST_REGULAR_ESTIMATE = os.path.join('data','selected_features','regular','estimate','test')
# ALL_FEAT_TRAIN_REGULAR_CLASSIFY = os.path.join('data','all_features','regular','classify','train')
# ALL_FEAT_TEST_REGULAR_CLASSIFY = os.path.join('data','all_features','regular','classify','test')
# ALL_FEAT_VAL_REGULAR_CLASSIFY = os.path.join('data','all_features','regular','classify','val')
# ALL_FEAT_TRAIN_REGULAR_ESTIMATE = os.path.join('data','all_features','regular','estimate','train')
# ALL_FEAT_VAL_REGULAR_ESTIMATE = os.path.join('data','all_features','regular','estimate','val')
# ALL_FEAT_TEST_REGULAR_ESTIMATE = os.path.join('data','all_features','regular','estimate','test')
# SEL_FEAT_TRAIN_NORMALIZED_CLASSIFY = os.path.join('data','selected_features','normalize','classify','train')
# SEL_FEAT_VAL_NORMALIZED_CLASSIFY = os.path.join('data','selected_features','normalize','classify','val')
# SEL_FEAT_TRAIN_NORMALIZED_ESTIMATE = os.path.join('data','selected_features','normalize','estimate','train')
# SEL_FEAT_VAL_NORMALIZED_ESTIMATE = os.path.join('data','selected_features','normalize','estimate','val')
# RESULTS_CLASSIFY = os.path.join('results','grid_search','classification')
# RESULTS_ESTIMATE = os.path.join('results','grid_search','regression')
# SEL_FEAT = os.path.join('data','selected_features')
# ALL_FEAT = os.path.join('data','all_features')
# ANOVA_DIR = os.path.join('results','anova')
# GRID_SEARCH_CLF_DIR = os.path.join('results','grid_search','classification')
# GRID_SEARCH_REG_DIR = os.path.join('results','grid_search','regression')


import os
import re
import sys
import csv
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import stats
from src.main import config

def get_combined_data(file1, file2):
    feature_df = pd.read_csv(file1)
    feature_df = feature_df.append(pd.read_csv(file2))
    train_split_df = pd.read_csv(config.TRAIN_SPLIT_FILE, 
                    usecols=['Participant_ID', 'PHQ_Binary'])
    feature_df = feature_df[feature_df['video'].isin(train_split_df['Participant_ID'])]
    print "features: ", feature_df.shape
    print "train_split: ", train_split_df.shape
    train_split_dict = train_split_df.set_index('Participant_ID').T.to_dict()
    del train_split_df
    labels = np.zeros(feature_df.shape[0])
    for i in xrange(feature_df.shape[0]):
        video_id = feature_df.iat[i,0]
        labels[i] = train_split_dict[video_id]['PHQ_Binary']
    feature_df['label'] = pd.Series(labels, index=feature_df.index)
    try:
        feature_df.drop(['video','question','starttime','endtime'], inplace=True, axis=1)
    except ValueError:
        feature_df.drop(['video','question'], inplace=True, axis=1)
    return feature_df
    


# Path: src/main/config.py
# TRAIN_SPLIT_FILE = os.path.join('data','classification_data','training_split.csv')
# TEST_SPLIT_FILE = os.path.join('data','classification_data','test_split.csv')
# VAL_SPLIT_FILE = os.path.join('data','classification_data','dev_split.csv')
# D_ND_DIR = os.path.join('data','disc_nondisc')
# POS_NEG_DIR = os.path.join('data','pos_neg')
# SEL_FEAT_TRAIN_REGULAR_CLASSIFY = os.path.join('data','selected_features','regular','classify','train')
# SEL_FEAT_TEST_REGULAR_CLASSIFY = os.path.join('data','selected_features','regular','classify','test')
# SEL_FEAT_VAL_REGULAR_CLASSIFY = os.path.join('data','selected_features','regular','classify','val')
# SEL_FEAT_TRAIN_REGULAR_ESTIMATE = os.path.join('data','selected_features','regular','estimate','train')
# SEL_FEAT_VAL_REGULAR_ESTIMATE = os.path.join('data','selected_features','regular','estimate','val')
# SEL_FEAT_TEST_REGULAR_ESTIMATE = os.path.join('data','selected_features','regular','estimate','test')
# ALL_FEAT_TRAIN_REGULAR_CLASSIFY = os.path.join('data','all_features','regular','classify','train')
# ALL_FEAT_TEST_REGULAR_CLASSIFY = os.path.join('data','all_features','regular','classify','test')
# ALL_FEAT_VAL_REGULAR_CLASSIFY = os.path.join('data','all_features','regular','classify','val')
# ALL_FEAT_TRAIN_REGULAR_ESTIMATE = os.path.join('data','all_features','regular','estimate','train')
# ALL_FEAT_VAL_REGULAR_ESTIMATE = os.path.join('data','all_features','regular','estimate','val')
# ALL_FEAT_TEST_REGULAR_ESTIMATE = os.path.join('data','all_features','regular','estimate','test')
# SEL_FEAT_TRAIN_NORMALIZED_CLASSIFY = os.path.join('data','selected_features','normalize','classify','train')
# SEL_FEAT_VAL_NORMALIZED_CLASSIFY = os.path.join('data','selected_features','normalize','classify','val')
# SEL_FEAT_TRAIN_NORMALIZED_ESTIMATE = os.path.join('data','selected_features','normalize','estimate','train')
# SEL_FEAT_VAL_NORMALIZED_ESTIMATE = os.path.join('data','selected_features','normalize','estimate','val')
# RESULTS_CLASSIFY = os.path.join('results','grid_search','classification')
# RESULTS_ESTIMATE = os.path.join('results','grid_search','regression')
# SEL_FEAT = os.path.join('data','selected_features')
# ALL_FEAT = os.path.join('data','all_features')
# ANOVA_DIR = os.path.join('results','anova')
# GRID_SEARCH_CLF_DIR = os.path.join('results','grid_search','classification')
# GRID_SEARCH_REG_DIR = os.path.join('results','grid_search','regression')


# Path: src/helpers/plot.py
import os
import re
import sys
import csv
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import stats
from src.main import config


def get_combined_data(file1, file2):
    feature_df = pd.read_csv(file1)
    feature_df = feature_df.append(pd.read_csv(file2))
    train_split_df = pd.read_csv(config.TRAIN_SPLIT_FILE, 
                    usecols=['Participant_ID', 'PHQ_Binary'])
    feature_df = feature_df[feature_df['video'].isin(train_split_df['Participant_ID'])]
    print "features: ", feature_df.shape
    print "train_split: ", train_split_df.shape
    train_split_dict = train_split_df.set_index('Participant_ID').T.to_dict()
    del train_split_df
    labels = np.zeros(feature_df.shape[0])
    for i in xrange(feature_df.shape[0]):
        video_id = feature_df.iat[i,0]
        labels[i] = train_split_dict[video_id]['PHQ_Binary']
    feature_df['label'] = pd.Series(labels, index=feature_df.index)
    try:
        feature_df.drop(['video','question','starttime','endtime'], inplace=True, axis=1)
    except ValueError:
        feature_df.drop(['video','question'], inplace=True, axis=1)
    return feature_df
    


def plot_boxplot(df, dir_name):