2
$\begingroup$

I would be happy if someone gives me a hint for two following questions in Machine Learning - related application of Classical Multidimensional Scaling in Matlab:

1.) It is recommended (but in my experience rarely done) to apply feature extraction (and hence the feature projection methods as Classical Multidimensional or PCA ) separately on the training, validation and test set to get a more realistic model performance estimation during the model validation. Furthermore, I would get the same question if I would apply my models after model deployment in a real environment with new data. How can I use the classical multidimensional scaling separately on independent data sets after I have trained my ML model? Do I firstly project my training data on the lower dimension and later provide this determined lower dimensionality to the Classical multidimensional scaling of validation/test/new data?

2.) Is the workflow right: data normalization --> classical multidimensional scaling --> again data normalization on the reduced data? I have provided an example code. I am appreciating every hint! Thank you very much!

Regards, Denys

%% Using of Hold-Out Validation with training, validation and test-set

%% Classical Multidimensional Scaling Training data
DataTrain = normalize(DataTrain); % normalization
D = pdist(DataTrain,'euclidean'); % pair-wise distances
[Y,e] = cmdscale(D); % carry out classical multidimensional scaling
CumSumEig = cumsum(e./sum(e)); % cumulated sum in order to identify the cumlated relevance
LowDim = find(CumSumEig > 0.95, 1, "first"); % dimensions with cumulated relevance over 95 % 
DataTrain = Y(:,1:LowDim); % reduced data

%% Validation 
% How to reduce the dimensionality of the validation data, because it is
% recommended to apply feature extraction (and hence the feature projection
% methods) separately on the training, validation and test set?
DataValidation = normalize(DataValidation); % normalization
D = pdist(DataValidation,'euclidean'); % pair-wise distances
[Y,e] = cmdscale(D); % carry out classical multidimensional scaling
DataValidation = Y(:,1:LowDim); % reduced data

%% or application to new data
DataNew = normalize(DataNew); % normalization
D = pdist(NewData,'euclidean'); % pair-wise distances
[Y,e] = cmdscale(D); % carry out classical multidimensional scaling
DataNew = Y(:,1:LowDim); % reduced data
% Again Data normalization before making predictions?
DataTrain = normalize(DataTrain);
DataNew = normalize(DataNew);

Additional information after some research (on 19.11.22): Taking in account the comments so far I agree that the application of Classical MDS on out-of-sample data is probably not a recommended approach. nevertheless I found after some research that my question might be answered in the following paper: "The out-of-sample problem for classical multidimensional scaling" (doi:10.1016/j.csda.2008.02.031).

$\endgroup$
6
  • $\begingroup$ Hi, please correct "How can I use the classical multidimensional scaling separately to use the with the training data developed model on the validation set etc.", it sounds incomplete. $\endgroup$
    – utobi
    Commented Nov 12, 2022 at 19:39
  • 1
    $\begingroup$ Hi utobi, thank you very much for the hint. I hope, now it is clearer:) $\endgroup$
    – De Ro
    Commented Nov 13, 2022 at 15:34
  • $\begingroup$ Classical MDS on Euclidean data is equivalent to PCA, see stats.stackexchange.com/a/132731/247165 Why would you run classical MDS on Euclidean data in the first place if you can do PCA? $\endgroup$ Commented Nov 15, 2022 at 11:10
  • $\begingroup$ Do not normalize once more after having run the MDS. As far as the MDS is not implicitly normalized, component variances are informative and should not be nullified by normalization (same as PCA). $\endgroup$ Commented Nov 15, 2022 at 11:23
  • $\begingroup$ Hi Christian Henning. Thanks for your reply. This really helped me. Do you mind to put this in an actual answer, so I can mark it as solved? $\endgroup$
    – De Ro
    Commented Nov 16, 2022 at 20:14

1 Answer 1

1
+50
$\begingroup$

If you do MDS on two different data sets, you get different subspaces of your original data space. If you train a ML model on one subspace, there is no reason to believe that same model would even work if applied on data taken in a different subspace, this is particularly evident if these subspaces can have different number of dimesion, but even if you fix them to have the same dimensionality (like you do) these dimension could be describing different axes or differentiating factors in the original data, and a model trained on a subspace could become meaningless in another different subspace.

Same goes for normalization: let's say you normalise your test data and you fit a forest/tree on it. You also normalise your test set, but this set of data has different scales and centers, so a data point that goes to 0 in the training set, would become something more or something less in the test set, depending on the mean and variances of this set. As a result, the tree or forest could route this data point to different leaves than it would have otherwise and result in a wrong prediction.

So, what you should do is this:

  • you normalize your training data, and then you use the same scaling parameters to rescale validation/test data (don't normalise them again from scratch)
  • you use MDS to learn a subspace from training data, then you use the same learned subspace to fit new data. I don't know how to do this on matlab because I never worked in matlab, but it's definitively possible with some other packages. Don't just save the number of dimensions from the training set, save the whole manifold, otherwise you could be learning different subspaces from each data set (that's particularly likely with MDS which is non-deterministic).
  • You train a model on your training set, and then you use that learned model to make predictions on new data.

Also follow the recommendations Christian gave you on the comments, those are both good advice.

$\endgroup$
2
  • $\begingroup$ @ carlo: Thank you very much for the detailed explanation! Regarding your second bullet point: Do you have a source or an example of the procedure for "use the same learned subspace to fit new data" for MDS? It does not need to be matlab, I can adapt it to matlab later. I am struggling to find a solution for the exact methodological steps. Thank you! $\endgroup$
    – De Ro
    Commented Nov 23, 2022 at 20:11
  • $\begingroup$ @DeRo I can't remeber anything about MDS implementations, but in sci-kit learn there is a MDS algorithm that can be fit on some training data and used to transform out-of-sample data, same as all methods and models in sci-kit learn. check out scikit-learn.org/stable/modules/generated/… $\endgroup$
    – carlo
    Commented Nov 25, 2022 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.