为矩阵的每一列创建向量并构造矩阵,但删除该列

发布于 2024-12-13 22:49:39 字数 505 浏览 6 评论 0原文

我已经从 matlab 中的 CSV 文件导入了一些数据。它们是全部对齐的时间序列(它们是时间序列这一事实并不重要,只是每列代表一个实体,行是该实体的观察结果)。这就是说,一个名为 data 的 2500x50 双精度矩阵和一个名为 colheaders 的 1x50 元胞数组。

我想做的是使用神经网络工具集从所有其他实体中预测每个实体(即列)。神经网络工具将“目标”(矩阵的单列)和“输入”(原始矩阵,但从矩阵中删除用作“目标”的同一列)作为输入。

假设 colheaders 中的条目的形式为 Col1、Col2、Col3 等。我想自动化训练模型并对原始矩阵的每一列进行预测的过程,以便我有作为输出一堆标记为 Predicted_Col1、Predicted_Col2 等的预测列。

我想我可以弄清楚神经网络部分,但我只是不知道如何开始矩阵操作和交叉引用colheaders 数组。这似乎是一件很常见的事情,所以我猜有人知道一种简单、直接、计算效率高的方法。谢谢。

I've imported some data from a CSV file in matlab. They are time series that are all aligned (the fact that they are time series is not important, just that each column represents a single entity, and the rows are observations for that entity). This give me say, a 2500x50 matrix of doubles called data and a 1x50 cell array called colheaders.

What I am trying to do is use the Neural Network toolset to predict each entity (i.e., column) from all the others. The Neural Network tool takes as input a "target" (a single column of the matrix) and "input" (the original matrix but with the same column used as "target" removed from the matrix).

Suppose the entries in colheaders are of the form Col1, Col2, Col3, etc. I'd like to automate the process of training the model and making predictions for each column of the original matrix so that I have as output a bunch of prediction columns labeled Predicted_Col1, Predicted_Col2, etc.

I think I can figure out the Neural Network part but I just don't know how to begin on the matrix manipulation and cross-referencing to the colheaders array. This seems like a common thing to want to do so I am guessing that someone knows an easy, straight-forward way to do it that is computationally efficient. Thanks.

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

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

发布评论

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

评论(1

故事和酒 2024-12-20 22:49:40

假设 colheaders 是字符串单元格,data 是 2500x50 输入数组,下面的代码将遍历 data 的所有列,将目标与输入分开,将其输入到 NN 的伪代码中,并逐渐构建预测矩阵,同时在 out_colheaders 中单独创建自定义列标题:

predicted = zeros(size(data));
for i = 1:size(data, 2)
    target = data(:, i);
    training_input = data;
    training_input(:, i) = [];
    // assuming the following function returns a column of 2500x1
    // given training_input of size 2500x49 and target 2500x1
    predicted(:, i) = pseudo_neural(training_input, target);
    out_colheaders{i} = ['Predicted_' colheaders{i}];
end

Assuming colheaders is a cell of strings and data is your 2500x50 input array, the code below goes through all columns of data, separates target from input, feeds it into a pseudo-code for NN, and gradually builds the predicted matrix while creating custom column headers separately in out_colheaders:

predicted = zeros(size(data));
for i = 1:size(data, 2)
    target = data(:, i);
    training_input = data;
    training_input(:, i) = [];
    // assuming the following function returns a column of 2500x1
    // given training_input of size 2500x49 and target 2500x1
    predicted(:, i) = pseudo_neural(training_input, target);
    out_colheaders{i} = ['Predicted_' colheaders{i}];
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文