필터 지우기
필터 지우기

Reorder dataset to find Sum of LSE between two data sets

조회 수: 1 (최근 30일)
Mostafa Asheghan
Mostafa Asheghan 2022년 5월 31일
답변: Vatsal 2023년 10월 6일
Hi,
Assume I have two datasets, each one containing 5000 samples, and each sample has three dimensions. I am looking for a way to "reorder" the samples in one (or probably both) dataset such that the sum of least square error between these two data sets be minimum.
Please see the attached photo for clarification.
Thanks.

답변 (1개)

Vatsal
Vatsal 2023년 10월 6일
Hi,
I understand that you have two datasets, each consisting of 5000 samples, and each sample has three dimensions. The objective is to rearrange the samples, in order to minimize the sum of the least square errors between the two datasets.
One simple solution to achieve this is by generating all possible permutations of the samples and then determining which ordering results in the minimum sum of least square errors. However, a more efficient approach is to utilize the "matchpairs" function in MATLAB, which is specifically designed to solve the linear assignment problem.
I am also attaching the code below that demonstrates the usage of the "matchpairs" function: -
% Example datasets
dataset1 = rand(5000, 3); % Replace with your dataset
dataset2 = rand(5000, 3); % Replace with your dataset
distances = pdist2(dataset1, dataset2);
costUnmatched = max(distances(:)) + 1;
% Apply matchpairs to find optimal assignment
assignment = matchpairs(distances, costUnmatched);
% Reorder dataset1 based on optimal assignment
reordered_dataset1 = dataset1(assignment(:, 1), :);
You can also refer to the MATLAB documentation for "matchpairs" to obtain more information on its usage and syntax. The link is provided below: -
I hope this helps!

카테고리

Help CenterFile Exchange에서 Multiobjective Optimization에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by