python - sklearn LDA unique labels issue -


i have code used run uses lda (linear discriminant analysis) class sklearn.lda module. gives error below. lately updated sklearn package, think might caused that. however, still not understand problem is. tell me wrong putting 1 , -1 labels? far understand problem related labeling.

traceback (most recent call last):    file "<ipython-input-94-9935ca0189ad>", line 1, in <module>     lda.fit([atom.coords atom in nm_1.atoms], nm_1.correlations[1][0])    file "c:\anaconda\lib\site-packages\sklearn\lda.py", line 415, in fit     self.classes_ = unique_labels(y)    file "c:\anaconda\lib\site-packages\sklearn\utils\multiclass.py", line 106, in unique_labels     raise valueerror("unknown label type: %r" % ys)  valueerror: unknown label type: array([ 1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,         1.,  1.,  1.,  1.,  1.,  1.,  1.,  1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,        -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.]) 

the problem not 1/-1 labeling, sklearn.lda works string labels:

>>>import numpy np >>>from sklearn.lda import lda >>>x = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]]) >>>y = np.array([1, 1, 1, "y","y","y"]) >>>clf = lda() >>>clf.fit(x, y) >>>(clf.predict([[-0.8, -1],[3,2]])) ['1' 'y'] 

you have problem labels object - sure array?


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -