How to print underscore variable in Python?

My code

import numpy as np
from pylab import plot,show
import scipy
import scipy.cluster
from scipy.cluster.vq import kmeans, vq

data_sillet = np.loadtxt('clustering_sillet.txt', delimiter=',')
data = data_sillet.astype(int)

print (type(data))

centroids, _ = scipy.cluster.vq.kmeans(data.astype(float), 3)
idx, _ = vq(data,centroids)

How to print all contents of throwaway variable, and not just print (centroids)?

+4
source share
1 answer

Instead

centroids, _ = scipy.cluster.vq.kmeans(data.astype(float), 3)

using

centroids, i_want_this = scipy.cluster.vq.kmeans(data.astype(float), 3)

and then print i_want_this.

+5
source

Source: https://habr.com/ru/post/1683619/


All Articles