# 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
        for median in bp['medians']:
            median.set(color='black', linewidth=3)

        for flier in bp['fliers']:
            flier.set(marker='o', color='green', alpha=0.7)
        #plt.show()
        #sys.exit(1)
        fig.savefig('plots/' + dir_name + '/' + feature + '.png')


def calculate_anova(df, filename):
    filename += '.csv'
    columns = df.columns[:-1]
    grouped_df = df.groupby(by='label')
    with open(os.path.join(config.ANOVA_DIR,filename), 'w') as csvfile:
        csv_writer = csv.writer(csvfile, delimiter=',')
        csv_writer.writerow(["Feature","P-value","F-value"])
        for feature in columns:
            data = []
            for key, item in grouped_df:
                temp_df = grouped_df.get_group(key)
                data.append(temp_df.loc[:,feature].values)
            
            f_val, p_val = stats.f_oneway(data[0], data[1])
            csv_writer.writerow([feature, p_val, f_val])
    

def main():
    filename = sys.argv[3]
    features_df = get_combined_data(os.path.join(config.D_ND_DIR, sys.argv[1]), 

# 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

        for median in bp['medians']:
            median.set(color='black', linewidth=3)

        for flier in bp['fliers']:
            flier.set(marker='o', color='green', alpha=0.7)
        #plt.show()
        #sys.exit(1)
        fig.savefig('plots/' + dir_name + '/' + feature + '.png')


def calculate_anova(df, filename):
    filename += '.csv'
    columns = df.columns[:-1]
    grouped_df = df.groupby(by='label')
    with open(os.path.join(config.ANOVA_DIR,filename), 'w') as csvfile:
        csv_writer = csv.writer(csvfile, delimiter=',')
        csv_writer.writerow(["Feature","P-value","F-value"])
        for feature in columns:
            data = []
            for key, item in grouped_df:
                temp_df = grouped_df.get_group(key)
                data.append(temp_df.loc[:,feature].values)
            
            f_val, p_val = stats.f_oneway(data[0], data[1])
            csv_writer.writerow([feature, p_val, f_val])
    

def main():
    filename = sys.argv[3]
    features_df = get_combined_data(os.path.join(config.D_ND_DIR, sys.argv[1]), 

                    os.path.join(config.D_ND_DIR, sys.argv[2]))