# Path: utility/datafilepath.py
# class DataFilePath:
#     def __init__(self):
#     def getOrderDir_Train(self):  
#     def getOrderDir_Test1(self):  
#     def getTest1Dir(self):
#     def getTest2Dir(self):
#     def getTrainDir(self):
#     def getGapCsv_Train(self):
#     def getGapCsv_Test1(self):
#     def getTestset1Readme(self):
#     def getTestset2Readme(self):
#     def getGapFilename(self):
#     def getGapPredictionFileName(self):
#     def getPrevGapFileName(self):
#     def get_dir_name(self, data_dir):
# 
# Path: utility/dumpload.py
# class DumpLoad:
#     def __init__(self, pickle_filepath):
#         self.pickle_filepath = pickle_filepath
#         dir_path = os.path.dirname(pickle_filepath)
#         if not os.path.exists(dir_path):
#             os.makedirs(dir_path)
#         
#         return
#     def load(self):
#         with open(self.pickle_filepath, 'rb') as handle:
#             dataset = pickle.load(handle)
#         return dataset
#     def isExisiting(self):
#         return os.path.exists(self.pickle_filepath) 
#     def run(self):
#         self.dump((np.arange(10), np.arange(20)))
#         print(self.load())
#         return
#     
#     def dump(self, dataset):
#         with open(self.pickle_filepath, 'wb') as f:
#             pickle.dump(dataset, f, pickle.HIGHEST_PROTOCOL)
#         return


from order import ExploreOrder
from utility.datafilepath import g_singletonDataFilePath
from visualization import visualizeData
from utility.dumpload import DumpLoad
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import math
import pandas as pd
class VisualizeTrainData(visualizeData):
    def __init__(self):
        ExploreOrder.__init__(self)
        visualizeData.__init__(self)
       
        
#         self.weathdf = self.load_weatherdf(data_dir)
        
        return
    def univariate(self):
#         self.gapdistricution()
#         self.weather_distribution()
#         self.traffic_districution()
        self.poi_distribution()
        
        return
    def poi_distribution(self):
#         dt_list = self.get_district_type_list()
#         dt_sum = pd.Series(np.zeros(len(dt_list)), index=dt_list)
#         dt_dict = self.get_district_type_dict()
#         for _, item_series in dt_dict.iteritems():
#             dt_sum = dt_sum + item_series
        df = self.get_district_type_table()
        dt_sum = df[self.get_district_type_list()].sum(axis = 0)
        print dt_sum.describe()
        dt_sum.plot(kind='bar')
        plt.xlabel('District Attribute')
        plt.title('Barplot of District Attribute')
        return
    def weather_distribution(self):

# Path: utility/datafilepath.py
# class DataFilePath:
#     def __init__(self):
#     def getOrderDir_Train(self):  
#     def getOrderDir_Test1(self):  
#     def getTest1Dir(self):
#     def getTest2Dir(self):
#     def getTrainDir(self):
#     def getGapCsv_Train(self):
#     def getGapCsv_Test1(self):
#     def getTestset1Readme(self):
#     def getTestset2Readme(self):
#     def getGapFilename(self):
#     def getGapPredictionFileName(self):
#     def getPrevGapFileName(self):
#     def get_dir_name(self, data_dir):
# 
# Path: utility/dumpload.py
# class DumpLoad:
#     def __init__(self, pickle_filepath):
#         self.pickle_filepath = pickle_filepath
#         dir_path = os.path.dirname(pickle_filepath)
#         if not os.path.exists(dir_path):
#             os.makedirs(dir_path)
#         
#         return
#     def load(self):
#         with open(self.pickle_filepath, 'rb') as handle:
#             dataset = pickle.load(handle)
#         return dataset
#     def isExisiting(self):
#         return os.path.exists(self.pickle_filepath) 
#     def run(self):
#         self.dump((np.arange(10), np.arange(20)))
#         print(self.load())
#         return
#     
#     def dump(self, dataset):
#         with open(self.pickle_filepath, 'wb') as f:
#             pickle.dump(dataset, f, pickle.HIGHEST_PROTOCOL)
#         return


# Path: exploredata/visualize_traindata.py
from order import ExploreOrder
from utility.datafilepath import g_singletonDataFilePath
from visualization import visualizeData
from utility.dumpload import DumpLoad
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import math
import pandas as pd

class VisualizeTrainData(visualizeData):
    def __init__(self):
        ExploreOrder.__init__(self)
        visualizeData.__init__(self)
       
        
#         self.weathdf = self.load_weatherdf(data_dir)
        
        return
    def univariate(self):
#         self.gapdistricution()
#         self.weather_distribution()
#         self.traffic_districution()
        self.poi_distribution()
        
        return
    def poi_distribution(self):
#         dt_list = self.get_district_type_list()
#         dt_sum = pd.Series(np.zeros(len(dt_list)), index=dt_list)
#         dt_dict = self.get_district_type_dict()
#         for _, item_series in dt_dict.iteritems():
#             dt_sum = dt_sum + item_series
        df = self.get_district_type_table()
        dt_sum = df[self.get_district_type_list()].sum(axis = 0)
        print dt_sum.describe()
        dt_sum.plot(kind='bar')
        plt.xlabel('District Attribute')
        plt.title('Barplot of District Attribute')
        return
    def weather_distribution(self):

        data_dir = g_singletonDataFilePath.getTrainDir()