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)
评论列表
文章目录