def doPCA(data, dimensions=2):
from sklearn.decomposition import PCA
model = PCA(n_components=dimensions, svd_solver='randomized', random_state=7)
model.fit(data)
return model
File "/home/dogus/Downloads/DAT210x-master/Module5/assignment4.py", line 221, in display_pca = doPCA(T)
File "/home/dogus/Downloads/DAT210x-master/Module5/assignment4.py", line 56, in doPCA model = PCA(n_components=dimensions, svd_solver='randomized', random_state=None)
TypeError: init() got an unexpected keyword argument 'random_state'
Edit:
Problem caused by Spyder? How can i fix it?
You are probably using an old version of sklearn. The docs say that the random_state variable was added in version 0.18.0. Try updating sklearn.
In order to make the update, look at these questions
Based on your comment, just to make sure the problem is not the scikit-learn version, try the following
def doPCA(data, dimensions=2):
from sklearn.decomposition import PCA
import sklearn
print sklearn.__version__
model = PCA(n_components=dimensions, svd_solver='randomized', random_state=7)
model.fit(data)
return model
This will only print the version of sklearn being used. As you said that you had also installed sklearn with pip, you could have conflicting versions.