11

When I run classifier.py in the openface demos directory using:

classifier.py train ./generated-embeddings/

I get the following error message:

--> from sklearn.lda import LDA

ModuleNotFoundError: No module named 'sklearn.lda'.

I think to have correctly installed sklearn.

What could be the reason for this message?

seralouk
  • 30,938
  • 9
  • 118
  • 133
mauroV8F5
  • 137
  • 1
  • 1
  • 6

3 Answers3

25

It seems that you have installed a newer version of sklearn but you are trying to call an old one.

1) First check your version

import sklearn
sklearn.__version__

2) Then use something like the following depending on the version that you have installed

from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA

Documentation here:

http://scikit-learn.org/stable/modules/generated/sklearn.discriminant_analysis.LinearDiscriminantAnalysis.html

seralouk
  • 30,938
  • 9
  • 118
  • 133
3

Best guess is that you're using the call for Linear Discriminant Analysis from sklearn 0.16, not the current version (0.19).

Try using sklearn.discriminant_analysis.LinearDiscriminantAnalysis instead.

Here's the link to the docs.

grundy
  • 31
  • 3
0

In case you are using new version and using

from sklearn.qda import QDA

it will give error, try

from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis