KL-SVD on Burgers equation

Example using KL-SVD on solutions of the Burgers equation.

from __future__ import annotations

import matplotlib.pyplot as plt

from gemseo import configure_logger
from gemseo.mlearning.transformers.dimension_reduction.klsvd import KLSVD
from gemseo.problems.dataset.burgers import create_burgers_dataset

configure_logger()
<RootLogger root (INFO)>

Load dataset

dataset = create_burgers_dataset(n_samples=20)
dataset
GROUP inputs outputs
VARIABLE t u_t
COMPONENT 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 ... 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
0 0.000000 -8.610583e-43 0.012566 0.025133 0.037699 0.050265 0.062832 0.075398 0.087965 0.100531 0.113097 0.125664 0.138230 0.150796 0.163363 0.175929 0.188496 0.201062 0.213628 0.226195 0.238761 0.251327 0.263894 0.276460 0.289027 0.301593 0.314159 0.326726 0.339292 0.351858 0.364425 0.376991 0.389557 0.402124 0.414690 0.427257 0.439823 0.452389 0.464956 0.477522 ... -0.490088 -0.477522 -0.464956 -0.452389 -0.439823 -0.427257 -0.414690 -0.402124 -0.389557 -0.376991 -0.364425 -0.351858 -0.339292 -0.326726 -0.314159 -0.301593 -0.289027 -0.276460 -0.263894 -0.251327 -0.238761 -0.226195 -0.213628 -0.201062 -0.188496 -0.175929 -0.163363 -0.150796 -0.138230 -0.125664 -0.113097 -0.100531 -0.087965 -0.075398 -0.062832 -0.050265 -0.037699 -0.025133 -0.012566 8.610583e-43
1 0.105263 -3.809524e-01 -0.369583 -0.358213 -0.346844 -0.335474 -0.324105 -0.312735 -0.301365 -0.289996 -0.278626 -0.267257 -0.255887 -0.244517 -0.233148 -0.221778 -0.210409 -0.199039 -0.187670 -0.176300 -0.164930 -0.153561 -0.142191 -0.130822 -0.119452 -0.108083 -0.096713 -0.085343 -0.073974 -0.062604 -0.051235 -0.039865 -0.028496 -0.017126 -0.005756 0.005613 0.016983 0.028352 0.039722 0.051091 ... -0.824366 -0.812996 -0.801627 -0.790257 -0.778887 -0.767518 -0.756148 -0.744779 -0.733409 -0.722040 -0.710670 -0.699300 -0.687931 -0.676561 -0.665192 -0.653822 -0.642453 -0.631083 -0.619713 -0.608344 -0.596974 -0.585605 -0.574235 -0.562866 -0.551496 -0.540126 -0.528757 -0.517387 -0.506018 -0.494648 -0.483279 -0.471909 -0.460539 -0.449170 -0.437800 -0.426431 -0.415061 -0.403692 -0.392322 -3.809524e-01
2 0.210526 -6.956522e-01 -0.685271 -0.674890 -0.664509 -0.654129 -0.643748 -0.633367 -0.622986 -0.612605 -0.602224 -0.591843 -0.581462 -0.571081 -0.560700 -0.550319 -0.539938 -0.529558 -0.519177 -0.508796 -0.498415 -0.488034 -0.477653 -0.467272 -0.456891 -0.446510 -0.436129 -0.425748 -0.415367 -0.404987 -0.394606 -0.384225 -0.373844 -0.363463 -0.353082 -0.342701 -0.332320 -0.321939 -0.311558 -0.301177 ... -1.100508 -1.090127 -1.079746 -1.069365 -1.058984 -1.048603 -1.038222 -1.027841 -1.017461 -1.007080 -0.996699 -0.986318 -0.975937 -0.965556 -0.955175 -0.944794 -0.934413 -0.924032 -0.913651 -0.903270 -0.892890 -0.882509 -0.872128 -0.861747 -0.851366 -0.840985 -0.830604 -0.820223 -0.809842 -0.799461 -0.789080 -0.778699 -0.768319 -0.757938 -0.747557 -0.737176 -0.726795 -0.716414 -0.706033 -6.956522e-01
3 0.315789 -9.600000e-01 -0.950450 -0.940899 -0.931349 -0.921798 -0.912248 -0.902697 -0.893147 -0.883596 -0.874046 -0.864496 -0.854945 -0.845395 -0.835844 -0.826294 -0.816743 -0.807193 -0.797642 -0.788092 -0.778542 -0.768991 -0.759441 -0.749890 -0.740340 -0.730789 -0.721239 -0.711689 -0.702138 -0.692588 -0.683037 -0.673487 -0.663936 -0.654386 -0.644835 -0.635285 -0.625735 -0.616184 -0.606634 -0.597083 ... -1.332467 -1.322917 -1.313366 -1.303816 -1.294265 -1.284715 -1.275165 -1.265614 -1.256064 -1.246513 -1.236963 -1.227412 -1.217862 -1.208311 -1.198761 -1.189211 -1.179660 -1.170110 -1.160559 -1.151009 -1.141458 -1.131908 -1.122358 -1.112807 -1.103257 -1.093706 -1.084156 -1.074605 -1.065055 -1.055504 -1.045954 -1.036404 -1.026853 -1.017303 -1.007752 -0.998202 -0.988651 -0.979101 -0.969550 -9.600000e-01
4 0.421053 -1.185185e+00 -1.176342 -1.167499 -1.158656 -1.149813 -1.140970 -1.132127 -1.123284 -1.114441 -1.105598 -1.096755 -1.087912 -1.079069 -1.070226 -1.061383 -1.052540 -1.043697 -1.034854 -1.026011 -1.017168 -1.008325 -0.999482 -0.990639 -0.981796 -0.972953 -0.964110 -0.955267 -0.946424 -0.937581 -0.928738 -0.919895 -0.911052 -0.902209 -0.893366 -0.884523 -0.875680 -0.866837 -0.857994 -0.849151 ... -1.530062 -1.521219 -1.512376 -1.503533 -1.494690 -1.485847 -1.477004 -1.468161 -1.459318 -1.450475 -1.441632 -1.432789 -1.423946 -1.415103 -1.406260 -1.397417 -1.388574 -1.379731 -1.370888 -1.362045 -1.353202 -1.344359 -1.335516 -1.326673 -1.317830 -1.308987 -1.300144 -1.291301 -1.282458 -1.273615 -1.264772 -1.255929 -1.247086 -1.238243 -1.229400 -1.220557 -1.211714 -1.202871 -1.194028 -1.185185e+00
5 0.526316 -1.379310e+00 -1.371077 -1.362844 -1.354611 -1.346378 -1.338145 -1.329912 -1.321678 -1.313445 -1.305212 -1.296979 -1.288746 -1.280513 -1.272280 -1.264046 -1.255813 -1.247580 -1.239347 -1.231114 -1.222881 -1.214648 -1.206414 -1.198181 -1.189948 -1.181715 -1.173482 -1.165249 -1.157016 -1.148782 -1.140549 -1.132316 -1.124083 -1.115850 -1.107617 -1.099384 -1.091150 -1.082917 -1.074684 -1.066451 ... -1.700349 -1.692128 -1.683904 -1.675679 -1.667451 -1.659222 -1.650993 -1.642762 -1.634531 -1.626299 -1.618067 -1.609835 -1.601603 -1.593370 -1.585137 -1.576905 -1.568672 -1.560439 -1.552206 -1.543973 -1.535740 -1.527507 -1.519274 -1.511040 -1.502807 -1.494574 -1.486341 -1.478108 -1.469875 -1.461642 -1.453409 -1.445175 -1.436942 -1.428709 -1.420476 -1.412243 -1.404010 -1.395777 -1.387543 -1.379310e+00
6 0.631579 -1.548387e+00 -1.540685 -1.532983 -1.525281 -1.517579 -1.509877 -1.502175 -1.494473 -1.486771 -1.479069 -1.471367 -1.463665 -1.455963 -1.448261 -1.440560 -1.432858 -1.425156 -1.417454 -1.409752 -1.402050 -1.394348 -1.386646 -1.378944 -1.371242 -1.363540 -1.355838 -1.348136 -1.340434 -1.332732 -1.325030 -1.317328 -1.309626 -1.301924 -1.294222 -1.286520 -1.278818 -1.271116 -1.263414 -1.255712 ... -1.531535 -1.587522 -1.631453 -1.665337 -1.690955 -1.709836 -1.723271 -1.732331 -1.737894 -1.740671 -1.741236 -1.740050 -1.737479 -1.733815 -1.729289 -1.724084 -1.718345 -1.712186 -1.705695 -1.698945 -1.691991 -1.684876 -1.677635 -1.670295 -1.662878 -1.655399 -1.647872 -1.640308 -1.632714 -1.625097 -1.617462 -1.609812 -1.602151 -1.594481 -1.586805 -1.579122 -1.571436 -1.563746 -1.556054 -1.548360e+00
7 0.736842 -1.696970e+00 -1.689735 -1.682499 -1.675264 -1.668029 -1.660794 -1.653559 -1.646323 -1.639088 -1.631853 -1.624618 -1.617383 -1.610147 -1.602912 -1.595677 -1.588442 -1.581207 -1.573972 -1.566736 -1.559501 -1.552266 -1.545031 -1.537796 -1.530560 -1.523325 -1.516090 -1.508855 -1.501620 -1.494385 -1.487149 -1.479914 -1.472679 -1.465444 -1.458209 -1.450973 -1.443738 -1.436503 -1.429268 -1.422033 ... 1.621381 1.624286 1.626100 1.626554 1.625314 1.621967 1.616009 1.606820 1.593654 1.575612 1.551629 1.520461 1.480683 1.430705 1.368816 1.293261 1.202368 1.094725 0.969402 0.826206 0.665921 0.490485 0.303035 0.107777 -0.090332 -0.286048 -0.474371 -0.651010 -0.812728 -0.957479 -1.084384 -1.193560 -1.285879 -1.362723 -1.425748 -1.476707 -1.517319 -1.549187 -1.573751 -1.592272e+00
8 0.842105 -1.828571e+00 -1.821750 -1.814928 -1.808106 -1.801284 -1.794463 -1.787641 -1.780819 -1.773997 -1.767176 -1.760354 -1.753532 -1.746710 -1.739889 -1.733067 -1.726245 -1.719424 -1.712602 -1.705780 -1.698958 -1.692137 -1.685315 -1.678493 -1.671671 -1.664850 -1.658028 -1.651206 -1.644384 -1.637563 -1.630741 -1.623919 -1.617097 -1.610276 -1.603454 -1.596632 -1.589810 -1.582989 -1.576167 -1.569345 ... 1.316236 1.323054 1.329870 1.336686 1.343500 1.350313 1.357123 1.363930 1.370734 1.377533 1.384328 1.391115 1.397895 1.404664 1.411421 1.418163 1.424885 1.431584 1.438253 1.444886 1.451473 1.458005 1.464467 1.470844 1.477114 1.483253 1.489229 1.495004 1.500529 1.505746 1.510581 1.514944 1.518725 1.521787 1.523961 1.525042 1.524779 1.522862 1.518920 1.512501e+00
9 0.947368 -1.945946e+00 -1.939493 -1.933040 -1.926587 -1.920134 -1.913681 -1.907228 -1.900775 -1.894322 -1.887869 -1.881416 -1.874963 -1.868510 -1.862057 -1.855604 -1.849151 -1.842698 -1.836245 -1.829792 -1.823339 -1.816886 -1.810433 -1.803980 -1.797527 -1.791074 -1.784621 -1.778168 -1.771715 -1.765262 -1.758809 -1.752356 -1.745903 -1.739450 -1.732997 -1.726544 -1.720091 -1.713638 -1.707185 -1.700732 ... 1.028888 1.035341 1.041794 1.048247 1.054700 1.061152 1.067605 1.074058 1.080511 1.086964 1.093417 1.099870 1.106323 1.112776 1.119229 1.125682 1.132135 1.138588 1.145040 1.151493 1.157946 1.164398 1.170851 1.177303 1.183755 1.190207 1.196659 1.203110 1.209562 1.216012 1.222463 1.228912 1.235361 1.241809 1.248256 1.254701 1.261145 1.267586 1.274026 1.280461e+00
10 1.052632 -2.051282e+00 -2.045160 -2.039038 -2.032916 -2.026794 -2.020672 -2.014550 -2.008428 -2.002305 -1.996183 -1.990061 -1.983939 -1.977817 -1.971695 -1.965573 -1.959451 -1.953329 -1.947207 -1.941085 -1.934963 -1.928840 -1.922718 -1.916596 -1.910474 -1.904352 -1.898230 -1.892108 -1.885986 -1.879864 -1.873742 -1.867620 -1.861498 -1.855376 -1.849253 -1.843131 -1.837009 -1.830887 -1.824765 -1.818643 ... 0.770996 0.777118 0.783240 0.789362 0.795484 0.801606 0.807728 0.813850 0.819973 0.826095 0.832217 0.838339 0.844461 0.850583 0.856705 0.862827 0.868949 0.875071 0.881193 0.887315 0.893437 0.899560 0.905682 0.911804 0.917926 0.924048 0.930170 0.936292 0.942414 0.948536 0.954658 0.960780 0.966902 0.973024 0.979146 0.985269 0.991391 0.997513 1.003635 1.009757e+00
11 1.157895 -2.146341e+00 -2.140518 -2.134695 -2.128871 -2.123048 -2.117224 -2.111401 -2.105577 -2.099754 -2.093931 -2.088107 -2.082284 -2.076460 -2.070637 -2.064813 -2.058990 -2.053166 -2.047343 -2.041520 -2.035696 -2.029873 -2.024049 -2.018226 -2.012402 -2.006579 -2.000755 -1.994932 -1.989109 -1.983285 -1.977462 -1.971638 -1.965815 -1.959991 -1.954168 -1.948345 -1.942521 -1.936698 -1.930874 -1.925051 ... 0.538264 0.544088 0.549911 0.555735 0.561558 0.567382 0.573205 0.579028 0.584852 0.590675 0.596499 0.602322 0.608146 0.613969 0.619793 0.625616 0.631439 0.637263 0.643086 0.648910 0.654733 0.660557 0.666380 0.672204 0.678027 0.683850 0.689674 0.695497 0.701321 0.707144 0.712968 0.718791 0.724614 0.730438 0.736261 0.742085 0.747908 0.753732 0.759555 7.653786e-01
12 1.263158 -2.232558e+00 -2.227006 -2.221453 -2.215900 -2.210348 -2.204795 -2.199243 -2.193690 -2.188137 -2.182585 -2.177032 -2.171480 -2.165927 -2.160375 -2.154822 -2.149269 -2.143717 -2.138164 -2.132612 -2.127059 -2.121506 -2.115954 -2.110401 -2.104849 -2.099296 -2.093744 -2.088191 -2.082638 -2.077086 -2.071533 -2.065981 -2.060428 -2.054876 -2.049323 -2.043770 -2.038218 -2.032665 -2.027113 -2.021560 ... 0.327182 0.332735 0.338287 0.343840 0.349393 0.354945 0.360498 0.366050 0.371603 0.377156 0.382708 0.388261 0.393813 0.399366 0.404918 0.410471 0.416024 0.421576 0.427129 0.432681 0.438234 0.443787 0.449339 0.454892 0.460444 0.465997 0.471549 0.477102 0.482655 0.488207 0.493760 0.499312 0.504865 0.510418 0.515970 0.521523 0.527075 0.532628 0.538180 5.437330e-01
13 1.368421 -2.311111e+00 -2.305805 -2.300500 -2.295194 -2.289888 -2.284582 -2.279276 -2.273971 -2.268665 -2.263359 -2.258053 -2.252747 -2.247441 -2.242136 -2.236830 -2.231524 -2.226218 -2.220912 -2.215607 -2.210301 -2.204995 -2.199689 -2.194383 -2.189078 -2.183772 -2.178466 -2.173160 -2.167854 -2.162549 -2.157243 -2.151937 -2.146631 -2.141325 -2.136020 -2.130714 -2.125408 -2.120102 -2.114796 -2.109491 ... 0.134863 0.140169 0.145475 0.150781 0.156086 0.161392 0.166698 0.172004 0.177310 0.182615 0.187921 0.193227 0.198533 0.203839 0.209144 0.214450 0.219756 0.225062 0.230368 0.235673 0.240979 0.246285 0.251591 0.256897 0.262202 0.267508 0.272814 0.278120 0.283426 0.288731 0.294037 0.299343 0.304649 0.309955 0.315260 0.320566 0.325872 0.331178 0.336484 3.417894e-01
14 1.473684 -2.382979e+00 -2.377899 -2.372819 -2.367739 -2.362659 -2.357579 -2.352499 -2.347419 -2.342339 -2.337259 -2.332179 -2.327098 -2.322018 -2.316938 -2.311858 -2.306778 -2.301698 -2.296618 -2.291538 -2.286458 -2.281378 -2.276298 -2.271218 -2.266138 -2.261058 -2.255978 -2.250898 -2.245818 -2.240738 -2.235658 -2.230578 -2.225498 -2.220418 -2.215338 -2.210258 -2.205178 -2.200098 -2.195018 -2.189938 ... -0.041089 -0.036008 -0.030928 -0.025848 -0.020768 -0.015688 -0.010608 -0.005528 -0.000448 0.004632 0.009712 0.014792 0.019872 0.024952 0.030032 0.035112 0.040192 0.045272 0.050352 0.055432 0.060512 0.065592 0.070672 0.075752 0.080832 0.085912 0.090992 0.096072 0.101152 0.106232 0.111312 0.116392 0.121472 0.126552 0.131632 0.136712 0.141792 0.146872 0.151952 1.570324e-01
15 1.578947 -2.448980e+00 -2.444107 -2.439234 -2.434362 -2.429489 -2.424616 -2.419744 -2.414871 -2.409998 -2.405126 -2.400253 -2.395380 -2.390507 -2.385635 -2.380762 -2.375889 -2.371017 -2.366144 -2.361271 -2.356399 -2.351526 -2.346653 -2.341781 -2.336908 -2.332035 -2.327163 -2.322290 -2.317417 -2.312545 -2.307672 -2.302799 -2.297927 -2.293054 -2.288181 -2.283309 -2.278436 -2.273563 -2.268691 -2.263818 ... -0.202677 -0.197804 -0.192931 -0.188059 -0.183186 -0.178313 -0.173441 -0.168568 -0.163695 -0.158823 -0.153950 -0.149077 -0.144205 -0.139332 -0.134459 -0.129587 -0.124714 -0.119841 -0.114969 -0.110096 -0.105223 -0.100351 -0.095478 -0.090605 -0.085733 -0.080860 -0.075987 -0.071115 -0.066242 -0.061369 -0.056497 -0.051624 -0.046751 -0.041878 -0.037006 -0.032133 -0.027260 -0.022388 -0.017515 -1.264243e-02
16 1.684211 -2.509804e+00 -2.505122 -2.500441 -2.495759 -2.491078 -2.486396 -2.481714 -2.477033 -2.472351 -2.467670 -2.462988 -2.458306 -2.453625 -2.448943 -2.444262 -2.439580 -2.434898 -2.430217 -2.425535 -2.420854 -2.416172 -2.411491 -2.406809 -2.402127 -2.397446 -2.392764 -2.388083 -2.383401 -2.378719 -2.374038 -2.369356 -2.364675 -2.359993 -2.355311 -2.350630 -2.345948 -2.341267 -2.336585 -2.331904 ... -0.351591 -0.346910 -0.342228 -0.337547 -0.332865 -0.328183 -0.323502 -0.318820 -0.314139 -0.309457 -0.304775 -0.300094 -0.295412 -0.290731 -0.286049 -0.281368 -0.276686 -0.272004 -0.267323 -0.262641 -0.257960 -0.253278 -0.248596 -0.243915 -0.239233 -0.234552 -0.229870 -0.225188 -0.220507 -0.215825 -0.211144 -0.206462 -0.201781 -0.197099 -0.192417 -0.187736 -0.183054 -0.178373 -0.173691 -1.690094e-01
17 1.789474 -2.566038e+00 -2.561533 -2.557028 -2.552523 -2.548018 -2.543513 -2.539008 -2.534503 -2.529998 -2.525493 -2.520988 -2.516484 -2.511979 -2.507474 -2.502969 -2.498464 -2.493959 -2.489454 -2.484949 -2.480444 -2.475939 -2.471434 -2.466929 -2.462424 -2.457920 -2.453415 -2.448910 -2.444405 -2.439900 -2.435395 -2.430890 -2.426385 -2.421880 -2.417375 -2.412870 -2.408365 -2.403860 -2.399355 -2.394851 ... -0.489267 -0.484762 -0.480257 -0.475752 -0.471247 -0.466743 -0.462238 -0.457733 -0.453228 -0.448723 -0.444218 -0.439713 -0.435208 -0.430703 -0.426198 -0.421693 -0.417188 -0.412683 -0.408179 -0.403674 -0.399169 -0.394664 -0.390159 -0.385654 -0.381149 -0.376644 -0.372139 -0.367634 -0.363129 -0.358624 -0.354119 -0.349614 -0.345110 -0.340605 -0.336100 -0.331595 -0.327090 -0.322585 -0.318080 -3.135751e-01
18 1.894737 -2.618182e+00 -2.613841 -2.609500 -2.605158 -2.600817 -2.596476 -2.592135 -2.587794 -2.583453 -2.579112 -2.574771 -2.570430 -2.566088 -2.561747 -2.557406 -2.553065 -2.548724 -2.544383 -2.540042 -2.535701 -2.531360 -2.527019 -2.522677 -2.518336 -2.513995 -2.509654 -2.505313 -2.500972 -2.496631 -2.492290 -2.487949 -2.483607 -2.479266 -2.474925 -2.470584 -2.466243 -2.461902 -2.457561 -2.453220 ... -0.616930 -0.612589 -0.608248 -0.603907 -0.599566 -0.595225 -0.590884 -0.586542 -0.582201 -0.577860 -0.573519 -0.569178 -0.564837 -0.560496 -0.556155 -0.551814 -0.547472 -0.543131 -0.538790 -0.534449 -0.530108 -0.525767 -0.521426 -0.517085 -0.512744 -0.508402 -0.504061 -0.499720 -0.495379 -0.491038 -0.486697 -0.482356 -0.478015 -0.473674 -0.469332 -0.464991 -0.460650 -0.456309 -0.451968 -4.476269e-01
19 2.000000 -2.666667e+00 -2.662478 -2.658289 -2.654100 -2.649912 -2.645723 -2.641534 -2.637345 -2.633156 -2.628968 -2.624779 -2.620590 -2.616401 -2.612212 -2.608024 -2.603835 -2.599646 -2.595457 -2.591268 -2.587080 -2.582891 -2.578702 -2.574513 -2.570324 -2.566136 -2.561947 -2.557758 -2.553569 -2.549381 -2.545192 -2.541003 -2.536814 -2.532625 -2.528437 -2.524248 -2.520059 -2.515870 -2.511681 -2.507493 ... -0.735634 -0.731446 -0.727257 -0.723068 -0.718879 -0.714690 -0.710502 -0.706313 -0.702124 -0.697935 -0.693746 -0.689558 -0.685369 -0.681180 -0.676991 -0.672803 -0.668614 -0.664425 -0.660236 -0.656047 -0.651859 -0.647670 -0.643481 -0.639292 -0.635103 -0.630915 -0.626726 -0.622537 -0.618348 -0.614159 -0.609971 -0.605782 -0.601593 -0.597404 -0.593216 -0.589027 -0.584838 -0.580649 -0.576460 -5.722716e-01

20 rows × 502 columns



t = dataset.input_dataset.to_numpy()[:, 0]
u_t = dataset.output_dataset.to_numpy()
t_split = 0.87

Plot dataset

def lines_gen():
    """Linestyle generator."""
    yield "-"
    for i in range(1, dataset.n_samples):
        yield 0, (i, 1, 1, 1)


color = "red"
lines = lines_gen()
for i in range(dataset.n_samples):
    # Switch mode if discontinuity is gone
    if color == "red" and t[i] > t_split:
        color = "blue"
        lines = lines_gen()  # reset linestyle generator

    plt.plot(u_t[i], color=color, linestyle=next(lines), label=f"t={t[i]:.2f}")

plt.legend()
plt.title("Solutions to Burgers equation")
plt.show()
Solutions to Burgers equation

Create KLSVD

n_modes = 7
klsvd = KLSVD(dataset.misc["x"], n_modes)
klsvd.fit(u_t)
u_t_reduced = klsvd.transform(u_t)
u_t_restored = klsvd.inverse_transform(u_t_reduced)
f"Dimension of the reduced space: {klsvd.output_dimension}"
'Dimension of the reduced space: 7'

Plot restored data

color = "red"
lines = lines_gen()
for i in range(dataset.n_samples):
    # Switch mode if discontinuity is gone
    if color == "red" and t[i] > t_split:
        color = "blue"
        lines = lines_gen()  # reset linestyle generator

    plt.plot(
        u_t_restored[i],
        color=color,  # linestyle=next(lines),
        label=f"t={t[i]:.2f}",
    )

plt.legend()
plt.title("Reconstructed solution after KLSVD reduction.")
plt.show()
Reconstructed solution after KLSVD reduction.

Total running time of the script: (0 minutes 0.700 seconds)

Gallery generated by Sphinx-Gallery