sklearn-doc-zh icon indicating copy to clipboard operation
sklearn-doc-zh copied to clipboard

TSNE示例代码有问题,报错

Open WithChameleon opened this issue 3 years ago • 2 comments

import numpy as np from sklearn.manifold import TSNE X = np.array([[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]]) X_embedded = TSNE(n_components=2, learning_rate='auto', init='random').fit_transform(X)

error:TypeError: ufunc 'multiply' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32')

WithChameleon avatar Oct 10 '21 15:10 WithChameleon

error: numpy.core._exceptions._UFuncNoLoopError: ufunc 'multiply' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32')) -> dtype('<U32')

WithChameleon avatar Oct 10 '21 15:10 WithChameleon

import numpy as np from sklearn.manifold import TSNE X = np.array([[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]]) X_embedded = TSNE(n_components=2, perplexity=1, learning_rate='auto', init='random').fit_transform(X)

It is working for numpy 1.23.5 and scikit-learn 1.2.2. You must provide a perplexity lower than n_components.

iTzAlver avatar May 03 '23 11:05 iTzAlver