{"id":1185829,"date":"2025-01-15T19:45:36","date_gmt":"2025-01-15T11:45:36","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1185829.html"},"modified":"2025-01-15T19:45:39","modified_gmt":"2025-01-15T11:45:39","slug":"%e5%a6%82%e4%bd%95%e7%bb%98%e5%88%b6%e9%ab%98%e7%bb%b4%e5%9b%bepython","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1185829.html","title":{"rendered":"\u5982\u4f55\u7ed8\u5236\u9ad8\u7ef4\u56fepython"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25134827\/15c1c04d-23ca-4478-9843-1b82f5b24a27.webp\" alt=\"\u5982\u4f55\u7ed8\u5236\u9ad8\u7ef4\u56fepython\" \/><\/p>\n<p><p> \u5728Python\u4e2d\u7ed8\u5236\u9ad8\u7ef4\u6570\u636e\u56fe\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u5de5\u5177\u548c\u6280\u672f\uff0c\u5305\u62ec<strong>\u4e3b\u6210\u5206\u5206\u6790\uff08PCA\uff09\u3001t-SNE\u3001UMAP\u3001P<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>rplot<\/strong>\u7b49\u3002\u4ee5\u4e0b\u662f\u8fd9\u4e9b\u6280\u672f\u7684\u7b80\u8981\u4ecb\u7ecd\uff0c\u5e76\u8be6\u7ec6\u63cf\u8ff0\u4e86\u5982\u4f55\u4f7f\u7528\u4e3b\u6210\u5206\u5206\u6790\uff08PCA\uff09\u6765\u7ed8\u5236\u9ad8\u7ef4\u6570\u636e\u56fe\u3002<\/p>\n<\/p>\n<p><p><strong>PCA\uff08\u4e3b\u6210\u5206\u5206\u6790\uff09\u3001t-SNE\u3001UMAP\u3001Pairplot<\/strong>\u662f\u5e38\u7528\u7684\u9ad8\u7ef4\u6570\u636e\u53ef\u89c6\u5316\u6280\u672f\u3002<strong>PCA<\/strong>\u662f\u4e00\u79cd\u7ebf\u6027\u964d\u7ef4\u65b9\u6cd5\uff0c\u9002\u5408\u4e8e\u6570\u636e\u95f4\u6709\u7ebf\u6027\u5173\u7cfb\u7684\u60c5\u51b5\uff1b<strong>t-SNE<\/strong>\u662f\u4e00\u79cd\u975e\u7ebf\u6027\u964d\u7ef4\u65b9\u6cd5\uff0c\u9002\u5408\u4e8e\u6355\u6349\u6570\u636e\u7684\u5c40\u90e8\u7ed3\u6784\uff1b<strong>UMAP<\/strong>\u662f\u4e00\u79cd\u65b0\u7684\u975e\u7ebf\u6027\u964d\u7ef4\u65b9\u6cd5\uff0c\u80fd\u66f4\u597d\u5730\u4fdd\u6301\u6570\u636e\u7684\u5168\u5c40\u7ed3\u6784\uff1b<strong>Pairplot<\/strong>\u53ef\u4ee5\u7ed8\u5236\u6570\u636e\u96c6\u4e2d\u6bcf\u5bf9\u7279\u5f81\u4e4b\u95f4\u7684\u5173\u7cfb\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001PCA\uff08\u4e3b\u6210\u5206\u5206\u6790\uff09<\/h3>\n<\/p>\n<p><p>\u4e3b\u6210\u5206\u5206\u6790\uff08PCA\uff09\u662f\u4e00\u79cd\u7ebf\u6027\u964d\u7ef4\u65b9\u6cd5\uff0c\u901a\u8fc7\u5c06\u9ad8\u7ef4\u6570\u636e\u6295\u5f71\u5230\u4f4e\u7ef4\u7a7a\u95f4\u4e2d\uff0c\u6765\u4fdd\u7559\u5c3d\u53ef\u80fd\u591a\u7684\u539f\u59cb\u6570\u636e\u7684\u65b9\u5dee\u3002PCA\u7684\u6838\u5fc3\u601d\u60f3\u662f\u901a\u8fc7\u6b63\u4ea4\u53d8\u6362\u5c06\u4e00\u7ec4\u53ef\u80fd\u5b58\u5728\u76f8\u5173\u6027\u7684\u53d8\u91cf\uff0c\u8f6c\u6362\u4e3a\u4e00\u7ec4\u7ebf\u6027\u4e0d\u76f8\u5173\u7684\u53d8\u91cf\uff0c\u5373\u4e3b\u6210\u5206\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5\u548c\u5bfc\u5165\u5fc5\u8981\u7684\u5e93<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>from sklearn.decomposition import PCA<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u751f\u6210\u6216\u5bfc\u5165\u6570\u636e<\/h4>\n<\/p>\n<p><p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u9ad8\u7ef4\u6570\u636e\u96c6\uff0c\u6570\u636e\u7ef4\u5ea6\u4e3a100\u7ef4\uff0c\u6837\u672c\u6570\u91cf\u4e3a500\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u968f\u673a\u9ad8\u7ef4\u6570\u636e<\/p>\n<p>np.random.seed(0)<\/p>\n<p>data = np.random.rand(500, 100)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u5e94\u7528PCA\u8fdb\u884c\u964d\u7ef4<\/h4>\n<\/p>\n<p><p>\u9009\u62e9\u964d\u7ef4\u540e\u7684\u7ef4\u5ea6\u6570\uff0c\u4f8b\u5982\u964d\u7ef4\u52302\u7ef4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># PCA\u964d\u7ef4<\/p>\n<p>pca = PCA(n_components=2)<\/p>\n<p>reduced_data = pca.fit_transform(data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4\u3001\u7ed8\u5236\u964d\u7ef4\u540e\u7684\u6570\u636e<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236\u4e8c\u7ef4PCA\u56fe<\/p>\n<p>plt.scatter(reduced_data[:, 0], reduced_data[:, 1])<\/p>\n<p>plt.xlabel(&#39;Principal Component 1&#39;)<\/p>\n<p>plt.ylabel(&#39;Principal Component 2&#39;)<\/p>\n<p>plt.title(&#39;PCA of High Dimensional Data&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001t-SNE\uff08t-Distributed Stochastic Neighbor Embedding\uff09<\/h3>\n<\/p>\n<p><p>t-SNE\u662f\u4e00\u79cd\u975e\u7ebf\u6027\u964d\u7ef4\u6280\u672f\uff0c\u80fd\u591f\u5c06\u9ad8\u7ef4\u6570\u636e\u6620\u5c04\u5230\u4e8c\u7ef4\u6216\u4e09\u7ef4\u7a7a\u95f4\u4e2d\uff0c\u540c\u65f6\u4fdd\u6301\u6570\u636e\u7684\u5c40\u90e8\u7ed3\u6784\u3002\u5b83\u7279\u522b\u9002\u5408\u4e8e\u9ad8\u7ef4\u6570\u636e\u7684\u53ef\u89c6\u5316\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5\u548c\u5bfc\u5165\u5fc5\u8981\u7684\u5e93<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.manifold import TSNE<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u5e94\u7528t-SNE\u8fdb\u884c\u964d\u7ef4<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># t-SNE\u964d\u7ef4<\/p>\n<p>tsne = TSNE(n_components=2, random_state=0)<\/p>\n<p>tsne_data = tsne.fit_transform(data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u7ed8\u5236\u964d\u7ef4\u540e\u7684\u6570\u636e<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236\u4e8c\u7ef4t-SNE\u56fe<\/p>\n<p>plt.scatter(tsne_data[:, 0], tsne_data[:, 1])<\/p>\n<p>plt.xlabel(&#39;t-SNE Component 1&#39;)<\/p>\n<p>plt.ylabel(&#39;t-SNE Component 2&#39;)<\/p>\n<p>plt.title(&#39;t-SNE of High Dimensional Data&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001UMAP\uff08Uniform Manifold Approximation and Projection\uff09<\/h3>\n<\/p>\n<p><p>UMAP\u662f\u4e00\u79cd\u65b0\u7684\u964d\u7ef4\u6280\u672f\uff0c\u5b83\u80fd\u591f\u66f4\u597d\u5730\u4fdd\u6301\u6570\u636e\u7684\u5168\u5c40\u7ed3\u6784\uff0c\u540c\u65f6\u4e5f\u80fd\u6709\u6548\u5730\u6355\u6349\u5c40\u90e8\u7ed3\u6784\u3002UMAP\u5728\u8bb8\u591a\u60c5\u51b5\u4e0b\u6bd4t-SNE\u66f4\u5feb\uff0c\u5e76\u4e14\u80fd\u591f\u66f4\u597d\u5730\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5\u548c\u5bfc\u5165\u5fc5\u8981\u7684\u5e93<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">!pip install umap-learn<\/p>\n<p>import umap<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u5e94\u7528UMAP\u8fdb\u884c\u964d\u7ef4<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># UMAP\u964d\u7ef4<\/p>\n<p>umap_reducer = umap.UMAP(n_components=2, random_state=0)<\/p>\n<p>umap_data = umap_reducer.fit_transform(data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u7ed8\u5236\u964d\u7ef4\u540e\u7684\u6570\u636e<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236\u4e8c\u7ef4UMAP\u56fe<\/p>\n<p>plt.scatter(umap_data[:, 0], umap_data[:, 1])<\/p>\n<p>plt.xlabel(&#39;UMAP Component 1&#39;)<\/p>\n<p>plt.ylabel(&#39;UMAP Component 2&#39;)<\/p>\n<p>plt.title(&#39;UMAP of High Dimensional Data&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001Pairplot<\/h3>\n<\/p>\n<p><p>Pairplot\u662f\u4e00\u79cd\u7b80\u5355\u4f46\u6709\u6548\u7684\u53ef\u89c6\u5316\u9ad8\u7ef4\u6570\u636e\u7684\u65b9\u6cd5\uff0c\u901a\u8fc7\u7ed8\u5236\u6570\u636e\u96c6\u4e2d\u6bcf\u5bf9\u7279\u5f81\u4e4b\u95f4\u7684\u5173\u7cfb\u6765\u5c55\u793a\u6570\u636e\u7684\u5206\u5e03\u548c\u76f8\u5173\u6027\u3002\u5b83\u7279\u522b\u9002\u5408\u4e8e\u5c0f\u89c4\u6a21\u6570\u636e\u96c6\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5\u548c\u5bfc\u5165\u5fc5\u8981\u7684\u5e93<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import seaborn as sns<\/p>\n<p>import pandas as pd<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u751f\u6210\u6216\u5bfc\u5165\u6570\u636e<\/h4>\n<\/p>\n<p><p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u6570\u636e\u96c6\uff0c\u5305\u542b5\u4e2a\u7279\u5f81\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u968f\u673a\u6570\u636e<\/p>\n<p>np.random.seed(0)<\/p>\n<p>data = np.random.rand(100, 5)<\/p>\n<p>columns = [f&#39;Feature{i}&#39; for i in range(1, 6)]<\/p>\n<p>df = pd.DataFrame(data, columns=columns)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u7ed8\u5236Pairplot<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236Pairplot<\/p>\n<p>sns.pairplot(df)<\/p>\n<p>plt.suptitle(&#39;Pairplot of High Dimensional Data&#39;, y=1.02)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u5bf9\u6bd4\u4e0e\u603b\u7ed3<\/h3>\n<\/p>\n<p><h4>1\u3001PCA<\/h4>\n<\/p>\n<p><p>PCA\u662f\u4e00\u79cd\u7ebf\u6027\u964d\u7ef4\u65b9\u6cd5\uff0c\u9002\u5408\u4e8e\u6570\u636e\u95f4\u6709\u7ebf\u6027\u5173\u7cfb\u7684\u60c5\u51b5\u3002\u5176\u4f18\u70b9\u662f\u8ba1\u7b97\u901f\u5ea6\u5feb\uff0c\u80fd\u591f\u4fdd\u7559\u5927\u90e8\u5206\u6570\u636e\u7684\u65b9\u5dee\u3002\u7f3a\u70b9\u662f\u4e0d\u80fd\u5f88\u597d\u5730\u5904\u7406\u975e\u7ebf\u6027\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>2\u3001t-SNE<\/h4>\n<\/p>\n<p><p>t-SNE\u662f\u4e00\u79cd\u975e\u7ebf\u6027\u964d\u7ef4\u65b9\u6cd5\uff0c\u80fd\u591f\u5f88\u597d\u5730\u6355\u6349\u6570\u636e\u7684\u5c40\u90e8\u7ed3\u6784\uff0c\u9002\u5408\u4e8e\u9ad8\u7ef4\u6570\u636e\u7684\u53ef\u89c6\u5316\u3002\u5176\u4f18\u70b9\u662f\u80fd\u6709\u6548\u5730\u5c55\u793a\u6570\u636e\u7684\u5c40\u90e8\u805a\u96c6\u60c5\u51b5\u3002\u7f3a\u70b9\u662f\u8ba1\u7b97\u590d\u6742\u5ea6\u9ad8\uff0c\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u96c6\u65f6\u6bd4\u8f83\u6162\u3002<\/p>\n<\/p>\n<p><h4>3\u3001UMAP<\/h4>\n<\/p>\n<p><p>UMAP\u662f\u4e00\u79cd\u65b0\u7684\u975e\u7ebf\u6027\u964d\u7ef4\u65b9\u6cd5\uff0c\u80fd\u591f\u66f4\u597d\u5730\u4fdd\u6301\u6570\u636e\u7684\u5168\u5c40\u7ed3\u6784\uff0c\u540c\u65f6\u4e5f\u80fd\u6709\u6548\u5730\u6355\u6349\u5c40\u90e8\u7ed3\u6784\u3002\u5176\u4f18\u70b9\u662f\u8ba1\u7b97\u901f\u5ea6\u8f83\u5feb\uff0c\u80fd\u591f\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\u3002\u7f3a\u70b9\u662f\u53c2\u6570\u8f83\u591a\uff0c\u8c03\u53c2\u8f83\u4e3a\u590d\u6742\u3002<\/p>\n<\/p>\n<p><h4>4\u3001Pairplot<\/h4>\n<\/p>\n<p><p>Pairplot\u662f\u4e00\u79cd\u7b80\u5355\u4f46\u6709\u6548\u7684\u53ef\u89c6\u5316\u9ad8\u7ef4\u6570\u636e\u7684\u65b9\u6cd5\uff0c\u9002\u5408\u4e8e\u5c0f\u89c4\u6a21\u6570\u636e\u96c6\u3002\u5176\u4f18\u70b9\u662f\u80fd\u591f\u76f4\u89c2\u5730\u5c55\u793a\u6570\u636e\u96c6\u4e2d\u6bcf\u5bf9\u7279\u5f81\u4e4b\u95f4\u7684\u5173\u7cfb\u3002\u7f3a\u70b9\u662f\u5f53\u7279\u5f81\u6570\u91cf\u8f83\u591a\u65f6\uff0c\u56fe\u5f62\u4f1a\u53d8\u5f97\u590d\u6742\uff0c\u4e0d\u6613\u89c2\u5bdf\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u5b9e\u9645\u5e94\u7528\u4e2d\u7684\u6ce8\u610f\u4e8b\u9879<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6570\u636e\u9884\u5904\u7406<\/strong>\uff1a\u5728\u8fdb\u884c\u964d\u7ef4\u4e4b\u524d\uff0c\u901a\u5e38\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u9884\u5904\u7406\uff0c\u4f8b\u5982\u6807\u51c6\u5316\u6216\u5f52\u4e00\u5316\u3002\u8fd9\u662f\u56e0\u4e3a\u5927\u591a\u6570\u964d\u7ef4\u65b9\u6cd5\u5bf9\u6570\u636e\u7684\u5c3a\u5ea6\u654f\u611f\uff0c\u6570\u636e\u7684\u4e0d\u540c\u5c3a\u5ea6\u4f1a\u5f71\u54cd\u964d\u7ef4\u7ed3\u679c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u5408\u9002\u7684\u964d\u7ef4\u65b9\u6cd5<\/strong>\uff1a\u6839\u636e\u6570\u636e\u7684\u7279\u6027\u548c\u5177\u4f53\u7684\u5e94\u7528\u573a\u666f\uff0c\u9009\u62e9\u5408\u9002\u7684\u964d\u7ef4\u65b9\u6cd5\u3002\u4f8b\u5982\uff0c\u82e5\u6570\u636e\u95f4\u6709\u660e\u663e\u7684\u7ebf\u6027\u5173\u7cfb\uff0c\u53ef\u4ee5\u9009\u62e9PCA\uff1b\u82e5\u6570\u636e\u95f4\u5b58\u5728\u590d\u6742\u7684\u975e\u7ebf\u6027\u5173\u7cfb\uff0c\u53ef\u4ee5\u9009\u62e9t-SNE\u6216UMAP\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u53c2\u6570\u8c03\u4f18<\/strong>\uff1a\u5927\u591a\u6570\u964d\u7ef4\u65b9\u6cd5\u90fd\u6709\u591a\u4e2a\u53c2\u6570\uff0c\u53ef\u4ee5\u901a\u8fc7\u8c03\u53c2\u6765\u4f18\u5316\u964d\u7ef4\u6548\u679c\u3002\u4f8b\u5982\uff0ct-SNE\u7684<code>perplexity<\/code>\u53c2\u6570\u3001UMAP\u7684<code>n_neighbors<\/code>\u53c2\u6570\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ed3\u679c\u89e3\u91ca<\/strong>\uff1a\u964d\u7ef4\u540e\u7684\u6570\u636e\u53ef\u89c6\u5316\u56fe\u5f62\u9700\u8981\u7ed3\u5408\u5177\u4f53\u7684\u4e1a\u52a1\u573a\u666f\u8fdb\u884c\u89e3\u91ca\u3002\u4f8b\u5982\uff0c\u901a\u8fc7\u964d\u7ef4\u7ed3\u679c\u53d1\u73b0\u6570\u636e\u7684\u805a\u7c7b\u7ed3\u6784\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u5206\u6790\u4e0d\u540c\u805a\u7c7b\u4e4b\u95f4\u7684\u7279\u5f81\u5dee\u5f02\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e03\u3001\u4ee3\u7801\u793a\u4f8b<\/h3>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7efc\u5408\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528PCA\u3001t-SNE\u548cUMAP\u5bf9\u540c\u4e00\u6570\u636e\u96c6\u8fdb\u884c\u964d\u7ef4\uff0c\u5e76\u7ed8\u5236\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>from sklearn.decomposition import PCA<\/p>\n<p>from sklearn.manifold import TSNE<\/p>\n<p>import umap<\/p>\n<h2><strong>\u751f\u6210\u968f\u673a\u9ad8\u7ef4\u6570\u636e<\/strong><\/h2>\n<p>np.random.seed(0)<\/p>\n<p>data = np.random.rand(500, 100)<\/p>\n<h2><strong>PCA\u964d\u7ef4<\/strong><\/h2>\n<p>pca = PCA(n_components=2)<\/p>\n<p>pca_data = pca.fit_transform(data)<\/p>\n<h2><strong>t-SNE\u964d\u7ef4<\/strong><\/h2>\n<p>tsne = TSNE(n_components=2, random_state=0)<\/p>\n<p>tsne_data = tsne.fit_transform(data)<\/p>\n<h2><strong>UMAP\u964d\u7ef4<\/strong><\/h2>\n<p>umap_reducer = umap.UMAP(n_components=2, random_state=0)<\/p>\n<p>umap_data = umap_reducer.fit_transform(data)<\/p>\n<h2><strong>\u7ed8\u5236PCA\u7ed3\u679c<\/strong><\/h2>\n<p>plt.figure(figsize=(12, 4))<\/p>\n<p>plt.subplot(1, 3, 1)<\/p>\n<p>plt.scatter(pca_data[:, 0], pca_data[:, 1])<\/p>\n<p>plt.xlabel(&#39;Principal Component 1&#39;)<\/p>\n<p>plt.ylabel(&#39;Principal Component 2&#39;)<\/p>\n<p>plt.title(&#39;PCA&#39;)<\/p>\n<h2><strong>\u7ed8\u5236t-SNE\u7ed3\u679c<\/strong><\/h2>\n<p>plt.subplot(1, 3, 2)<\/p>\n<p>plt.scatter(tsne_data[:, 0], tsne_data[:, 1])<\/p>\n<p>plt.xlabel(&#39;t-SNE Component 1&#39;)<\/p>\n<p>plt.ylabel(&#39;t-SNE Component 2&#39;)<\/p>\n<p>plt.title(&#39;t-SNE&#39;)<\/p>\n<h2><strong>\u7ed8\u5236UMAP\u7ed3\u679c<\/strong><\/h2>\n<p>plt.subplot(1, 3, 3)<\/p>\n<p>plt.scatter(umap_data[:, 0], umap_data[:, 1])<\/p>\n<p>plt.xlabel(&#39;UMAP Component 1&#39;)<\/p>\n<p>plt.ylabel(&#39;UMAP Component 2&#39;)<\/p>\n<p>plt.title(&#39;UMAP&#39;)<\/p>\n<p>plt.suptitle(&#39;Comparison of Dimensionality Reduction Techniques&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001\u7ed3\u8bba<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\u7ed8\u5236\u9ad8\u7ef4\u6570\u636e\u56fe\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u964d\u7ef4\u65b9\u6cd5\uff0c\u5982PCA\u3001t-SNE\u3001UMAP\u548cPairplot\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u7f3a\u70b9\u548c\u9002\u7528\u573a\u666f\uff0c\u6839\u636e\u6570\u636e\u7684\u7279\u6027\u548c\u5177\u4f53\u7684\u4e1a\u52a1\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u81f3\u5173\u91cd\u8981\u3002\u540c\u65f6\uff0c\u964d\u7ef4\u7ed3\u679c\u7684\u89e3\u91ca\u9700\u8981\u7ed3\u5408\u5177\u4f53\u7684\u4e1a\u52a1\u80cc\u666f\uff0c\u624d\u80fd\u5f97\u5230\u6709\u610f\u4e49\u7684\u7ed3\u8bba\u3002\u901a\u8fc7\u4e0d\u65ad\u5730\u5c1d\u8bd5\u548c\u8c03\u4f18\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u7406\u89e3\u548c\u5c55\u793a\u9ad8\u7ef4\u6570\u636e\u7684\u7ed3\u6784\u548c\u7279\u5f81\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u9ad8\u7ef4\u6570\u636e\u53ef\u89c6\u5316\u7684\u6700\u4f73\u65b9\u6cd5\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u5728\u5904\u7406\u9ad8\u7ef4\u6570\u636e\u65f6\uff0c\u5e38\u7528\u7684\u53ef\u89c6\u5316\u65b9\u6cd5\u5305\u62ec\u964d\u7ef4\u6280\u672f\uff0c\u5982\u4e3b\u6210\u5206\u5206\u6790\uff08PCA\uff09\u3001t-SNE\u548cUMAP\u3002\u8fd9\u4e9b\u6280\u672f\u80fd\u591f\u6709\u6548\u5730\u5c06\u9ad8\u7ef4\u6570\u636e\u6295\u5f71\u5230\u4f4e\u7ef4\u7a7a\u95f4\uff08\u901a\u5e38\u662f2D\u62163D\uff09\uff0c\u4f7f\u5f97\u6570\u636e\u7684\u7ed3\u6784\u548c\u6a21\u5f0f\u66f4\u52a0\u660e\u663e\u3002\u9009\u62e9\u5408\u9002\u7684\u964d\u7ef4\u65b9\u6cd5\u53d6\u51b3\u4e8e\u6570\u636e\u7684\u7279\u5f81\u548c\u53ef\u89c6\u5316\u7684\u76ee\u6807\u3002<\/p>\n<p><strong>Python\u4e2d\u6709\u54ea\u4e9b\u5e93\u53ef\u4ee5\u7528\u4e8e\u9ad8\u7ef4\u56fe\u7684\u7ed8\u5236\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u5e38\u7528\u7684\u5e93\u5305\u62ecMatplotlib\u3001Seaborn\u3001Plotly\u548cBokeh\u3002Matplotlib\u548cSeaborn\u9002\u5408\u57fa\u7840\u7684\u53ef\u89c6\u5316\u9700\u6c42\uff0c\u800cPlotly\u548cBokeh\u5219\u66f4\u9002\u5408\u4ea4\u4e92\u5f0f\u56fe\u8868\u5236\u4f5c\u3002\u6b64\u5916\uff0cscikit-learn\u5e93\u63d0\u4f9b\u4e86\u591a\u79cd\u964d\u7ef4\u7b97\u6cd5\uff0c\u53ef\u4ee5\u4e0e\u8fd9\u4e9b\u53ef\u89c6\u5316\u5e93\u7ed3\u5408\u4f7f\u7528\uff0c\u4ee5\u5b9e\u73b0\u9ad8\u7ef4\u6570\u636e\u7684\u53ef\u89c6\u5316\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u9ad8\u7ef4\u6570\u636e\u7684\u53ef\u89c6\u5316\u4e2d\u7684\u6570\u636e\u4e22\u5931\u6216\u566a\u58f0\u95ee\u9898\uff1f<\/strong><br \/>\u9ad8\u7ef4\u6570\u636e\u5e38\u5e38\u5b58\u5728\u566a\u58f0\u548c\u5197\u4f59\u7279\u5f81\uff0c\u8fd9\u53ef\u80fd\u5f71\u54cd\u53ef\u89c6\u5316\u7684\u6548\u679c\u3002\u5728\u8fdb\u884c\u53ef\u89c6\u5316\u4e4b\u524d\uff0c\u53ef\u4ee5\u8003\u8651\u5bf9\u6570\u636e\u8fdb\u884c\u9884\u5904\u7406\uff0c\u5982\u7279\u5f81\u9009\u62e9\u3001\u5f52\u4e00\u5316\u548c\u6807\u51c6\u5316\u3002\u4f7f\u7528PCA\u7b49\u964d\u7ef4\u65b9\u6cd5\u65f6\uff0c\u53ef\u4ee5\u9009\u62e9\u4fdd\u7559\u8f83\u9ad8\u7684\u65b9\u5dee\u6bd4\u4f8b\uff0c\u4ee5\u786e\u4fdd\u91cd\u8981\u4fe1\u606f\u88ab\u4fdd\u7559\u3002\u540c\u65f6\uff0c\u6570\u636e\u6e05\u7406\u548c\u5904\u7406\u4e5f\u80fd\u5e2e\u52a9\u51cf\u5c11\u566a\u58f0\u5bf9\u53ef\u89c6\u5316\u7ed3\u679c\u7684\u5f71\u54cd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u7ed8\u5236\u9ad8\u7ef4\u6570\u636e\u56fe\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u5de5\u5177\u548c\u6280\u672f\uff0c\u5305\u62ec\u4e3b\u6210\u5206\u5206\u6790\uff08PCA\uff09\u3001t-SNE\u3001UMAP\u3001PAI [&hellip;]","protected":false},"author":3,"featured_media":1185838,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1185829"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1185829"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1185829\/revisions"}],"predecessor-version":[{"id":1185842,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1185829\/revisions\/1185842"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1185838"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1185829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1185829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1185829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}