降低维度后,在子空间中绘制新点

发布于 2025-02-06 18:13:02 字数 214 浏览 3 评论 0原文

我想在2维图上绘制每个参数为100个参数,每个参数在0-99之间。这应该是通过降低维数(PCA/TSNE/UMAP等)的正常方法直接的,但是我需要能够将随后的点添加到图中,而无需重新计算并因此改变

我正在构图的算法,该算法需要数据点使用它的100个值并将其转换为x,y坐标,然后可以绘制。在原始100D空间中,2D投影中的点近端是近端。这样的算法是否存在?如果没有,有其他方法吗?

谢谢

I would like to plot points with 100 parameters each with values between 0-99 on a 2 dimensional plot. This should be straightforward with normal methods of dimensionality reduction (PCA/tSNE/UMAP etc) but I need to be able to add subsequent points to the plot without it needing to recalculate and therefore change

I am picturing an algorithm that takes a data-point with it's 100 values and converts it to X,Y coordinates that can then be plotted. Points proximal in the 2D projection are proximal in the original 100D space. Does such an algorithm exist? If not, any alternative approaches?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你的占有欲 2025-02-13 18:13:02

我不确定我是否正确理解了这个问题,但是有了初始集x,我们可以安装PCA来计算主要组件。然后,我们可以使用这些主要组件来转换新样本。

from sklearn.decomposition import PCA
import numpy as np
import matplotlib.pyplot as plt

n_samples, n_feats = 50, 100
X = np.random.randint(0, 99, size=n_samples * n_feats).reshape(n_samples, n_feats)

pca = PCA(n_components=2).fit(X)
X_reduced = pca.transform(X)

plt.scatter(X[:, 0], X[:, 1])

这幅图,

然后,当新样本进来时,

new_sample = np.random.randint(0, 99, size=100).reshape(1, 100)
new_sample_reduced = pca.transform(new_sample)
plt.scatter(new_sample_reduced[:, 0], new_sample_reduced[:, 1], color="red")

可以绘制

“新样本的绘图”

I am not sure I understood the question correctly but with an initial set X, we can fit a PCA to compute the principal components. Then, we can use these principal components to transform new samples.

from sklearn.decomposition import PCA
import numpy as np
import matplotlib.pyplot as plt

n_samples, n_feats = 50, 100
X = np.random.randint(0, 99, size=n_samples * n_feats).reshape(n_samples, n_feats)

pca = PCA(n_components=2).fit(X)
X_reduced = pca.transform(X)

plt.scatter(X[:, 0], X[:, 1])

This plots,

Plotting of X

Then, when a new sample comes in

new_sample = np.random.randint(0, 99, size=100).reshape(1, 100)
new_sample_reduced = pca.transform(new_sample)
plt.scatter(new_sample_reduced[:, 0], new_sample_reduced[:, 1], color="red")

We can plot it

Plotting of new sample

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文