gca.py 文件源码

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

项目:scikit-discovery 作者: MITHaystack 项目源码 文件源码
def process(self, obj_data):
        ''' 
        Perform component analysis on data

        Results are added to the data wrapper as a dictionary with
        results['CA'] = Eigenvenctors
        results['Projection'] = Projection on to the eigenvectors

        @param obj_data: Data wrapper
        '''

        component_type = self.ap_paramList[0]()
        start_time = self.ap_paramList[1]()
        end_time = self.ap_paramList[2]()

        num_components = self.n_components

        results = dict()
        results['start_date'] = start_time
        results['end_date'] = end_time

        cut_data = []
        label_list = []
        for label, data  in obj_data.getIterator():
            for column in self.column_names:
                cut_data.append(data.loc[start_time:end_time, column])
                label_list.append(label)

        cut_data = np.array(cut_data)

        if len(cut_data) > 0:
            if component_type == 'ICA' :
                ca = FastICA(n_components = num_components)
            else:
                ca = PCA(n_components = num_components)

                time_projection = ca.fit_transform(cut_data.T)
                results['CA'] = ca
                results['Projection'] = time_projection

        else:
            results['CA'] = None
            results['Projection'] = None

        results['labels'] = label_list

        obj_data.addResult(self.str_description, results)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号