victor-von-pooh / Clairvoyant

データの拡充と意思決定
MIT License
0 stars 0 forks source link

VAE の精度が高くない件について #1

Open victor-von-pooh opened 2 months ago

victor-von-pooh commented 2 months ago

VAE の KL ダイバージェンスでの評価実験の結果

Commit ID: https://github.com/victor-von-pooh/Clairvoyant/tree/512dfd681b98a6a2c95fa8129b2691f96205ddee

VAE モデルをデフォルト config で走らせると次のような結果が出る.

2024-06-19 19:22:29,458 - experiment_tools.start_logging - INFO - commit id: 512dfd681b98a6a2c95fa8129b2691f96205ddee
2024-06-19 19:22:29,459 - experiment_tools.start_logging - INFO - username: victor-von-pooh
2024-06-19 19:22:29,474 - experiment_tools.start_logging - INFO - OS infomation: 

    OS: Darwin 21.2.0
    Processor: i386
    Machine: x86_64
    Node: akitayaacBookea
    Python Version: 3.12.3

2024-06-19 19:22:31,347 - experiment_tools.start_logging - INFO - pip3 list:

Package           Version
----------------- -----------
contourpy         1.2.1
cycler            0.12.1
filelock          3.15.1
fonttools         4.53.0
fsspec            2024.6.0
Jinja2            3.1.4
joblib            1.4.2
kiwisolver        1.4.5
MarkupSafe        2.1.5
matplotlib        3.9.0
mpmath            1.3.0
networkx          3.3
numpy             1.26.4
packaging         24.1
pandas            2.2.2
pillow            10.3.0
pip               24.0
pyparsing         3.1.2
python-dateutil   2.9.0.post0
pytz              2024.1
scikit-learn      1.5.0
scipy             1.13.1
six               1.16.0
sympy             1.12.1
threadpoolctl     3.5.0
torch             2.2.2
tqdm              4.66.4
typing_extensions 4.12.2
tzdata            2024.1

2024-06-19 19:22:31,349 - experiment_tools.start_logging - INFO - diff: 

2024-06-19 19:22:31,349 - experiment_tools.start_logging - INFO - device: cpu
2024-06-19 19:22:31,423 - experiment_tools.start_logging - INFO - original data records: 1000
2024-06-19 19:22:31,423 - experiment_tools.start_logging - INFO - train data records: 20
2024-06-19 19:22:31,423 - experiment_tools.start_logging - INFO - valid data records: 20
2024-06-19 19:22:31,452 - experiment_tools.start_logging - INFO - train raw data:

    Feature_1  Feature_2  Feature_3  Feature_4  Feature_5  Feature_6  Feature_7  Feature_8  Feature_9  Feature_10
0          24        7.4     152000        0.6          5        0.5         62         75     376.57           4
1          53        2.3     198000       -0.5          5        9.4         44         40     408.97          -2
2          52        2.5     103000        0.3          3        3.4         89          0     331.10           4
3          27        6.2     154000        1.0          1        9.2         93         35     414.87           0
4          23        1.6      79000        0.7          2        9.7         51         25     337.64          -1
5          21        7.1     148000        0.4          1        0.4         56          0     225.61           0
6          60        9.0     126000        0.1          5        3.9         87         60     479.19          -1
7          58        5.8      93000        1.0          5        9.2         81         30     456.96          -5
8          58        6.9       7000        0.4          1        3.8         31         85     150.67          -4
9          45        5.7      29000        0.0          4        8.6         27         15     461.72          -2
10         54        3.4      73000        0.9          1        5.0         54         65     155.00          -4
11         16        7.4     154000       -0.3          3        0.6         46         25     460.68           4
12         39        5.9     198000       -0.2          3        3.4         60         90     326.58           4
13         21        0.0      71000        0.7          2        4.9          1         85     222.56           1
14         19        6.8      32000        0.1          2        1.9         59         35     285.05           5
15         45        7.0     122000        0.2          1        4.2         83         45     215.72           5
16         51        3.0      42000        0.2          4        0.6          2         40     298.42          -2
17         64        8.5     174000       -0.1          1        0.7         35         25     343.95          -4
18         46        9.6      38000        1.0          4        6.7         97          0     192.51          -3
19         48        5.7      87000        1.0          5        8.1          0         60     480.40          -3

2024-06-19 19:22:31,465 - experiment_tools.start_logging - INFO - model architecture:

VAE(
  (encoder): Sequential(
    (0): Linear(in_features=10, out_features=32, bias=True)
    (1): ReLU()
    (2): Linear(in_features=32, out_features=32, bias=True)
    (3): ReLU()
  )
  (mu_layer): Linear(in_features=32, out_features=2, bias=True)
  (logvar_layer): Linear(in_features=32, out_features=2, bias=True)
  (decoder): Sequential(
    (0): Linear(in_features=2, out_features=32, bias=True)
    (1): ReLU()
    (2): Linear(in_features=32, out_features=32, bias=True)
    (3): ReLU()
    (4): Linear(in_features=32, out_features=10, bias=True)
    (5): Sigmoid()
  )
)

2024-06-19 19:22:41,849 - experiment_tools.start_logging - INFO - predicted data:

      Feature_1  Feature_2      Feature_3  Feature_4  Feature_5  Feature_6  Feature_7  Feature_8   Feature_9  Feature_10
0     42.600281   5.866580  110218.570312   0.428658   3.074170   5.217875  56.132259  45.128628  339.997162    0.174258
1     44.787125   6.183745  117730.406250   0.485122   3.248748   5.630626  59.975510  48.895264  353.625854    0.605274
2     45.071800   6.217615  119443.656250   0.485645   3.268175   5.723142  60.748035  48.700741  354.879028    0.636057
3     43.502167   6.011938  113321.429688   0.453804   3.157583   5.398370  57.841728  46.829391  345.888794    0.365702
4     45.548992   6.275405  120603.921875   0.500292   3.299255   5.768045  61.295090  50.105072  358.839111    0.710487
...         ...        ...            ...        ...        ...        ...        ...        ...         ...         ...
1995  45.214622   6.245523  119857.984375   0.489996   3.279915   5.749880  60.960617  48.972870  356.172760    0.658550
1996  44.223518   6.108051  116994.445312   0.474607   3.205203   5.567621  58.759975  47.651127  351.326385    0.418155
1997  43.676949   6.028704  115397.468750   0.461031   3.162693   5.467710  57.822735  46.772301  347.503662    0.302553
1998  44.052334   6.062654  115601.054688   0.469944   3.174276   5.521293  58.182262  47.544823  349.079742    0.389820
1999  44.294186   6.092695  116055.710938   0.473566   3.200169   5.534237  58.943115  48.118080  350.378876    0.481435

[2000 rows x 10 columns]

2024-06-19 19:22:41,864 - experiment_tools.start_logging - INFO - KL divergence: 0.3953488966053363

KL ダイバージェンスの値は 0.3953488966053363 とだいぶ大きい. 実際に生成されたデータを見ても, Feature_1 では 42〜46 の辺りにまとまっており, 他の特徴量についても学習データに比べてスケールが圧倒的に小さい.
これを改善できるように実験 config の値をいくつか変更して, 試してみる. ただし, データは変更しないものとする.

参考資料

victor-von-pooh commented 2 months ago

VAE 実験: モデルの次元操作

リンク $\rightarrow$ Commit ID: https://github.com/victor-von-pooh/Clairvoyant/tree/bdcf4cce40f83c14f93061a310f75bf0751bb7db