Unsupervised Learning in Python
Benjamin Wilson
Director of Research at lateral.io
PCA
is a scikit-learn component like KMeans
or StandardScaler
fit()
learns the transformation from given datatransform()
applies the learned transformationtransform()
can also be applied to new datasamples
= array of two features (total_phenols
&od280
)[[ 2.8 3.92]
...
[ 2.05 1.6 ]]
from sklearn.decomposition import PCA
model = PCA() model.fit(samples)
PCA()
transformed = model.transform(samples)
print(transformed)
[[ 1.32771994e+00 4.51396070e-01]
[ 8.32496068e-01 2.33099664e-01]
...
[ -9.33526935e-01 -4.60559297e-01]]
total_phenols
and od280
components_
attribute of PCA objectprint(model.components_)
[[ 0.64116665 0.76740167]
[-0.76740167 0.64116665]]
Unsupervised Learning in Python