How to export PCA to use in another program I'm trying to write a random forest classifier for a very large dataset, as such as part of the pre-processing i have applied PCA to reduce from 643 features to 5 PC's. Is it possible to export these settings so I can 

pca.transform(data) 


in another program. 

I have been able to do this to the the scaler using pickle but when i run the transfrom i get given the error:
Traceback (most recent call last):

  File "&lt;ipython-input-35-68c9849c2acc&gt;", line 1, in &lt;module&gt;
    pca.transform(data)

TypeError: transform() missing 1 required positional argument: 'X'
Ideally PCA should not be used as a part of pre-processing feature reduction. 

Anyhow regarding saving and reusing PCA model, sharing a basic code snippet which is working very fine in my case(as I'm not able to reproduce the error case).

from sklearn.decomposition import PCA
import pickle as pk
pca = PCA(n_components=2)
result = pca.fit_transform(X) # Assume X is having more than 2 dimensions    
pk.dump(pca, open("pca.pkl","wb"))
.
.
.
# later reload the pickle file
pca_reload = pk.load(open("pca.pkl",'rb'))
result_new = pca_reload .transform(X)


# result and result_new same in my case