-
Notifications
You must be signed in to change notification settings - Fork 207
Expand file tree
/
Copy pathpca.py
More file actions
30 lines (22 loc) · 692 Bytes
/
pca.py
File metadata and controls
30 lines (22 loc) · 692 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
# -*- coding:utf-8 -*-
'''
-------------------------------------------------
Description : PCA
Author : machinelp
Date : 2020-06-15
-------------------------------------------------
'''
import numpy as np
from sklearn.externals import joblib
from sklearn.decomposition import PCA
class PCADecomposition(object):
def __init__(self, n_components=256):
self.pca = PCA(n_components=n_components)
def fit(self, data):
self.pca.fit( data )
return self
def transform(self, data):
return self.pca.transform( data )
def save_model(self, save_path):
#保存模型
joblib.dump(self.pca, save_path)