FeatureEngineering.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:kaggle 作者: RankingAI 项目源码 文件源码
def run(self, tasks, MonthsOfTest):
        """"""
        print('\nLoad data ...')
        start = time.time()
        ## load train
        with open('%s/1.pkl' % self._InputDir, 'rb') as i_file:
            self.TrainData = pickle.load(i_file)
        i_file.close()
        for i in range(2,MonthsOfTest[0]):
            with open('%s/%s.pkl' % (self._InputDir, i), 'rb') as i_file:
                df_tmp = pickle.load(i_file)
                self.TrainData = pd.concat([self.TrainData, df_tmp], ignore_index = True)
            i_file.close()
        ## load test
        with open('%s/%s.pkl' % (self._InputDir, MonthsOfTest[0]), 'rb') as i_file:
            self.TestData = pickle.load(i_file)
        i_file.close()
        for i in MonthsOfTest[1: ]:
            with open('%s/%s.pkl' % (self._InputDir, i), 'rb') as i_file:
                df_tmp = pickle.load(i_file)
                self.TestData = pd.concat([self.TestData, df_tmp], ignore_index = True)
            i_file.close()
        end = time.time()
        print('Load data done, time consumed %ds ...' % (end - start))

        ## tasks for l2 test
        print('\nLaunch task ...')
        start = time.time()
        for task in tasks:
            self.__LaunchTask(task, MonthsOfTest)
        end = time.time()
        if (os.path.exists(self._OutputDir) == False):
            os.makedirs(self._OutputDir)
        with open('%s/train.pkl' % self._OutputDir, 'wb') as o_file:
            pickle.dump(self.TrainData, o_file, -1)
        o_file.close()
        with open('%s/test.pkl' % self._OutputDir, 'wb') as o_file:
            pickle.dump(self.TestData, o_file, -1)
        o_file.close()
        print('All tasks done, time consumed %ds ...' % (end - start))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号