简体   繁体   中英

How do I plot a multidimensional array?

I have a multi-dimensional array that is the centroid of Kmeans output. Its size is (10,6). I want to see the location of these centroids in a plot, but I do not know how can I plot them in a plane. I tried to add a cluster column to the array like this center['cluster']=clusterNumber and the clusterNumber is a float array that contains cluster number, but it produces an error:

IndexError: only integers, slices (`:`), ellipsis (`...`), NumPy.newaxis (`None`) and integer or boolean arrays are valid indices

Do you know what is the problem and how can I plot this multidimensional array? The centroid array is:

19.6135 19.8452 19.9962 20.1065 20.1966 20.2832
26.5262 29.6227 31.4583 32.7302 33.7162 34.6274
13.3404 13.268  13.2414 13.2246 13.2134 13.2087
44.3025 47.7419 49.3674 50.5635 51.4984 52.3669
58.331  63.568  66.6059 69.222  71.03   72.5983
23.26   25.2503 26.5113 27.3892 28.0659 28.6797
38.6445 42.4035 44.3822 45.5953 46.591  47.4789
30.3485 33.8124 35.8269 37.2325 38.3075 39.2721
48.3545 53.1971 56.0548 58.1482 59.7034 61.11
34.8697 38.4072 40.2917 41.5594 42.5017 43.3741

Looking at the shape of your array, it only makes sense that it has 10 or 6 centroids (depending on the logic of your code). That said, each of your centroids can only have 6 or 10 dimensions (again, depending on the logic of your code), and this is a problem, as our brain can only observe at most 3 dimensions. However, you can get an idea of how your centroids look like in 3 dimensions by applying a projection. Take a look at this question to get an idea of how to do that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM