我正在嘗試將一個大維矩陣減少到僅 2D,我正在使用 2D 數組的示例,它有效,但我需要為更高維的散點做同樣的事情。我有兩個類,每個類都有 50x20 維特征空間的矩陣。對于我的例子,我有這些二維數組:rectangles = np.array([[1,1.5,1.7,1.45,1.1,1.6,1.8],[1.8,1.55,1.45,1.6,1.65,1.7,1.75]])triangles = np.array([[0.1,0.5,0.25,0.4,0.3,0.6,0.35,0.15,0.4,0.5,0.48],[1.1,1.5,1.3,1.2,1.15,1.0,1.4,1.2,1.3,1.5,1.0]])之后我找到了三角形和矩形類的均值# Calculate the mean vectors per classmean_rectangles = np.mean(rectangles,axis=1).reshape(2,1) mean_triangles = np.mean(triangles,axis=1).reshape(2,1)通過矩形和三角形類給出的值,我用它們來計算散點:scatter_triangles = np.dot((triangles-mean_triangles),(triangles-mean_triangles).T)scatter_circles = np.dot((circles-mean_circles),(circles-mean_circles).T)# Calculate the SW by adding the scatters within classes SW = scatter_triangles+scatter_circles+scatter_rectanglesprint(SW)plt.show()我想知道如何找到類內的散點并以完全相同的方式繪制它們,但對于更大的數據,恰好是 50x20 矩陣?
如何計算 50x20 矩陣的類內散點
慕蓋茨4494581
2023-02-07 11:03:57