我试图用yellowbrick包中的t-SNE可视化数据。我犯了个错误。你知道吗
import pandas as pd
from yellowbrick.text import TSNEVisualizer
from sklearn.datasets import make_classification
## produce random data
X, y = make_classification(n_samples=200, n_features=100,
n_informative=20, n_redundant=10,
n_classes=3, random_state=42)
## visualize data with t-SNE
tsne = TSNEVisualizer()
tsne.fit(X, y)
tsne.poof()
错误(由拟合方法引发):
ValueError: The truth value of an array with more than one element
is ambiguous. Use a.any() or a.all()
在对这些论点进行了一些实验之后:
这不会引起错误,但不会产生输出。你知道吗
最后,替换为字符串列表是可行的:
这个库是用来分析文本数据集的,也许这就是为什么y不需要是字符串的原因。此外,错误消息也没有帮助。你知道吗
相关问题 更多 >
编程相关推荐