TypeError: list indications must be integrers or slies, not str integer? str? I'm not sure.

Asked 2 years ago, Updated 2 years ago, 81 views

TypeError: list indications must be integrers or slies, not str error, but I don't know how to solve it, I tried int instead of str, but it didn't work.

//tsne = TSNE(random_state=0, n_iter=300, learning_rate=100)
X_tsne = tsne.fit_transform(X_sub)
plt.figure(figsize=(10, 10))
plt.xlim(X_tsne[:, 0].min(), X_tsne[:, 0].max() + 1)
plt.ylim(X_tsne[:, 1].min(), X_tsne[:, 1].max() + 1)
for i in range(len(X)):
    # Use numeric text to draw a scatterplot
    plt.text(X_tsne[i, 0], X_tsne[i, 1], str(X.target[i]),
             color = colors[X.target[i]],
             fontdict={'weight': 'bold', 'size': 9})
plt.xlabel("t-SNE feature 0")
plt.xlabel("t-SNE feature 1")

typeerror python

2022-09-20 19:31

1 Answers

X.target[i] must be the string.


2022-09-20 19:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.