如何将 tsne() 应用于 MATLAB 表格数据?
How to apply tsne() to MATLAB tabular data?
我在 MATLAB 中有一个 33000 x 1975 table,显然在我做任何进一步分析之前需要降维。特征是 1975 年的列,行是数据的实例。我尝试在 MATLAB table 上使用 tsne() 函数,但似乎 tsne() 仅适用于数值数组。问题是有没有办法在我的 MATLAB table 上应用 tsne。 table 由数字和字符串数据类型组成,因此 table2array() 在我的情况下无法将 table 转换为数字数组。
此外,从 MATHWORKS 文档看来,以应用于 fisheriris 数据集为例,tsne() 将特征列作为函数参数。因此,我需要将预测因子与共振因子分开,这应该不是问题。但是,最初,我似乎对如何进一步使用 tsne 感到困惑。在这方面的任何建议将不胜感激。
你或许可以使用 table
indexing using {}
to get out the data that you want. Here's a simple example adapted from the tsne
reference page:
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)
我在 MATLAB 中有一个 33000 x 1975 table,显然在我做任何进一步分析之前需要降维。特征是 1975 年的列,行是数据的实例。我尝试在 MATLAB table 上使用 tsne() 函数,但似乎 tsne() 仅适用于数值数组。问题是有没有办法在我的 MATLAB table 上应用 tsne。 table 由数字和字符串数据类型组成,因此 table2array() 在我的情况下无法将 table 转换为数字数组。 此外,从 MATHWORKS 文档看来,以应用于 fisheriris 数据集为例,tsne() 将特征列作为函数参数。因此,我需要将预测因子与共振因子分开,这应该不是问题。但是,最初,我似乎对如何进一步使用 tsne 感到困惑。在这方面的任何建议将不胜感激。
你或许可以使用 table
indexing using {}
to get out the data that you want. Here's a simple example adapted from the tsne
reference page:
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)