-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeature.py
More file actions
44 lines (31 loc) · 926 Bytes
/
feature.py
File metadata and controls
44 lines (31 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from sklearn.decomposition import PCA
class FeatureSelection:
'''
Provides different implementation of dimension reduction
'''
def __init__(self) -> None:
pass
def pca_model(self,
X,
num_pca_components=8):
'''
Applies PCA technique for dimension reduction
Parameters
----------
X: np.array
n-dim input data of spikes
num_pca_components: int
Desired dimennsion of data
Return
------
self.__pca_model: PCA
PCA model to find principal components
'''
self.__pca_model = PCA(n_components = num_pca_components).fit(X)
return self.__pca_model
def pca_features(self,
X):
'''
Applies fitted PCA model on spike data
'''
return self.__pca_model.fit_transform(X)