File size: 515 Bytes
16188ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from sklearn.decomposition import PCA as pca


class BaseDimensionReduction:
    def dimension_reduction(self,X):
        raise NotImplementedError()

class PCA(BaseDimensionReduction):
    def __init__(self, n_components: int = 0.8, *args, **kwargs) -> None:
        super().__init__()
        self.pca = pca(n_components,*args,**kwargs)


    def dimension_reduction(self, X):
        self.pca.fit(X=X)
        print(f'>>> The reduced dimension is {self.pca.n_components_}.')
        return self.pca.transform(X)