haifengl / smile

Statistical Machine Intelligence & Learning Engine
https://haifengl.github.io
Other
6.04k stars 1.13k forks source link

SammonMapping unexpected escape condition #386

Closed folterj closed 5 years ago

folterj commented 5 years ago

The SammonMapping has an unexpected escape condition:

if (lambda < 1E-3) {
    logger.info(String.format("Sammon's Mapping stress after %3d iterations: %.5f", iter-1, stress));
    break;
}

The SammonMapping correctly converges / escapes on: 1. stress, 2. number of iterations This additional escape condition makes the function terminate at unexpected intervals, where lambda does not converge but just varies. Removing this condition resolved my issue, which is the only solution as this does not appear to be parameterised.

Smile version: 1.5.2

haifengl commented 5 years ago

lambda is the step size in diagonal Newton method. The above condition is for early stop as the step is so small that the search won't progress much in general. In your case, the objective function is probably very flat given your data. So we may want no early stop as long as you don't care the time. How many iterations it keeps going after lambda is smaller than 0.001?

We may remove the early stop behavior or add an additional parameter to enable/disable early stop.

folterj commented 5 years ago

Thank you for responding - sorry for the slow response, just recently got back to this. As originally mentioned the lamda does not converge, our data does not have an optimal solution. Below is an example of a smaller data set (with larger initial lamdas) - note that the stress level does converge, while the lamda fluctuates and in this case actually increases.

[main] INFO smile.netlib.ARPACK - ARPACK: 20 iterations for Matrix of size 74 [main] INFO smile.netlib.ARPACK - ARPACK computed 2 eigenvalues INFO: Sammon's Mapping initial stress: 0.19635 INFO: Sammon's Mapping stress after 10 iterations: 0.15879, magic = 0.000 INFO: Sammon's Mapping stress after 20 iterations: 0.15850, magic = 0.000 INFO: Sammon's Mapping stress after 30 iterations: 0.14141, magic = 0.020 INFO: Sammon's Mapping stress after 40 iterations: 0.11352, magic = 0.009 INFO: Sammon's Mapping stress after 50 iterations: 0.09953, magic = 0.021 INFO: Sammon's Mapping stress after 60 iterations: 0.06128, magic = 0.241 INFO: Sammon's Mapping stress after 70 iterations: 0.04824, magic = 0.500 INFO: Sammon's Mapping stress after 80 iterations: 0.04759, magic = 0.500 INFO: Sammon's Mapping stress after 90 iterations: 0.04736, magic = 0.225 INFO: Sammon's Mapping stress after 100 iterations: 0.04721, magic = 0.500 INFO: Sammon's Mapping stress after 110 iterations: 0.04718, magic = 0.500

(edit: better example data found)

haifengl commented 5 years ago

We support a customized parameter to control the early stop behavior in v2.