首页 > 解决方案 > 如何将 tsne() 应用于 MATLAB 表格数据?

问题描述

我在 MATLAB 中有一个 33000 x 1975 的表,在我做任何进一步的分析之前显然需要降维。特征是 1975 列,行是数据的实例。我尝试在 MATLAB 表上使用 tsne() 函数,但似乎 tsne() 仅适用于数值数组。问题是有一种方法可以在我的 MATLAB 表上应用 tsne。该表由数字和字符串数据类型组成,因此 table2array() 在我的情况下不适用于将表转换为数字数组。此外,从 MATHWORKS 文档看来,以应用到 f​​isheriris 数据集为例, tsne() 将特征列作为函数参数。因此,我需要将预测变量与共振分开,这应该不是问题。但是,最初,我如何进一步使用 tsne 似乎令人困惑。在这方面的任何建议将不胜感激。

标签: matlabmachine-learningfeature-extractionfeature-selection

解决方案


您可能可以使用table索引{}来获取所需的数据。这是一个改编自tsne参考页面的简单示例:

load fisheriris
% Make a table where the first variable is the species name,
% and the other variables are the measurements
data = table(species, meas(:,1), meas(:,2), meas(:,3), meas(:,4))
% Use {} indexing on 'data' to extract a numeric matrix, then
% call 'tsne' on that
Y = tsne(data{:, 2:end});
% plot as per example.
gscatter(Y(:,1),Y(:,2),data.species)

推荐阅读