Paper Figures
This document describes the figures that can be generated using the paper-figures.py
script.
Available Figures
1. Route Length Distribution
- File:
route_length_distribution.{pdf,html}
- Description: Visualizes the distribution of route lengths across different datasets (training, n1, and n5 datasets).
- Generated by:
plot_route_length_distribution()
2. Leaf Distribution
- File:
leaf_distribution.{pdf,html}
- Description: Shows the distribution of leaf nodes (end states) across different datasets.
- Generated by:
plot_leaf_distribution()
3. Convergent Route Analysis
Two figures are generated for convergent route analysis:
- Files:
convergent_fraction_by_length.{pdf,html}
convergent_fraction_overall.{pdf,html}
- Description: Analyzes the fraction of convergent routes by length and overall convergent fraction across datasets.
- Generated by:
plot_convergent_fraction_by_length()
andplot_convergent_fraction_overall()
4. Top-K Accuracy Analysis
- File:
{dataset_name}_topk_accuracy_subplots.{pdf,html}
- Description: Comparative bar plots showing top-k accuracy metrics for different models and configurations.
- Features: Shows accuracy for k values [1, 2, 3, 4, 5, 10]
- Generated separately for n1 and n5 datasets
5. Route Processing Stages
- File:
{dataset_name}_route_processing_stages_{config}.{pdf,html}
- Description: Visualizes different stages of route processing, comparing:
- Valid routes
- Processed routes without stock
- Processed routes with stock
- True routes
6. Accuracy by Route Length
- File:
accuracy_by_length_subplots_{config}.{pdf,html}
- Description: Shows top-k accuracy metrics broken down by route length
- Features:
- Compares performance across different datasets (n1, n5)
- Shows accuracy for k=1 and k=10
Usage
To generate these figures, modify the rerun
dictionary in paper-figures.py
to specify which figures you want to generate:
rerun = {
"route-distribution": False,
"leaf-distribution": False,
"convergent-fraction": False,
"topk-accuracy": False,
"extraction-distribution": True,
"accuracy-by-length": False,
}
Set the corresponding flag to True
for the figures you want to generate. All figures will be saved in both PDF and HTML formats in the data/figures/paper
directory.
Source Code
directmultistep.analysis.paper.dataset_analysis
create_convergent_fraction_trace(path_strings, route_lengths, label, color)
Create a bar trace showing fraction of convergent routes by length.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_strings
|
list[str]
|
List of path strings to analyze |
required |
route_lengths
|
list[int]
|
List of corresponding route lengths |
required |
label
|
str
|
Label for the trace |
required |
color
|
str
|
Color for the trace |
required |
Returns:
Type | Description |
---|---|
Bar
|
Bar trace showing convergent fraction by length |
Source code in src/directmultistep/analysis/paper/dataset_analysis.py
create_leaf_bar_trace(path_strings, label, color)
Create a bar trace showing distribution of number of leaves at root node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_strings
|
list[str]
|
List of path strings to analyze |
required |
label
|
str
|
Label for the trace |
required |
color
|
str
|
Color for the trace |
required |
Returns:
Type | Description |
---|---|
Bar
|
Bar trace showing leaf distribution |
Source code in src/directmultistep/analysis/paper/dataset_analysis.py
create_split_bar_trace(route_lengths, label, sep_threshold, color)
Create two bar traces split by a threshold value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
route_lengths
|
list[int]
|
List of route lengths to plot |
required |
label
|
str
|
Label for the traces |
required |
sep_threshold
|
int
|
Threshold value to split traces |
required |
color
|
str
|
Color for both traces |
required |
Returns:
Type | Description |
---|---|
tuple[Bar, Bar]
|
Tuple of two bar traces - one for values <= threshold, one for values > threshold |
Source code in src/directmultistep/analysis/paper/dataset_analysis.py
plot_convergent_fraction_by_length(train_paths, train_lengths, n1_paths, n1_lengths, n5_paths, n5_lengths)
Create a plot showing fraction of convergent routes by length for different datasets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
train_paths
|
list[str]
|
List of path strings from training set |
required |
train_lengths
|
list[int]
|
List of route lengths from training set |
required |
n1_paths
|
list[str]
|
List of path strings from n1 dataset |
required |
n1_lengths
|
list[int]
|
List of route lengths from n1 dataset |
required |
n5_paths
|
list[str]
|
List of path strings from n5 dataset |
required |
n5_lengths
|
list[int]
|
List of route lengths from n5 dataset |
required |
Returns:
Type | Description |
---|---|
Figure
|
Plotly figure object containing the visualization |
Source code in src/directmultistep/analysis/paper/dataset_analysis.py
plot_convergent_fraction_overall(train_paths, n1_paths, n5_paths)
Create a plot showing overall fraction of convergent routes for different datasets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
train_paths
|
list[str]
|
List of path strings from training set |
required |
n1_paths
|
list[str]
|
List of path strings from n1 dataset |
required |
n5_paths
|
list[str]
|
List of path strings from n5 dataset |
required |
Returns:
Type | Description |
---|---|
Figure
|
Plotly figure object containing the visualization |
Source code in src/directmultistep/analysis/paper/dataset_analysis.py
plot_leaf_distribution(train_paths, n1_paths, n5_paths)
Create a plot showing the distribution of number of leaves for different datasets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
train_paths
|
list[str]
|
List of path strings from training set |
required |
n1_paths
|
list[str]
|
List of path strings from n1 dataset |
required |
n5_paths
|
list[str]
|
List of path strings from n5 dataset |
required |
Returns:
Type | Description |
---|---|
Figure
|
Plotly figure object containing the visualization |
Source code in src/directmultistep/analysis/paper/dataset_analysis.py
plot_route_length_distribution(train_steps, n1_steps, n5_steps)
Create a split plot showing the distribution of route lengths for different datasets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
train_steps
|
list[int]
|
List of route lengths from training set |
required |
n1_steps
|
list[int]
|
List of route lengths from n1 dataset |
required |
n5_steps
|
list[int]
|
List of route lengths from n5 dataset |
required |
Returns:
Type | Description |
---|---|
Figure
|
Plotly figure object containing the visualization |
Source code in src/directmultistep/analysis/paper/dataset_analysis.py
directmultistep.analysis.paper.linear_vs_convergent
ModelPlotConfig
dataclass
Configuration for model plotting.
Attributes:
Name | Type | Description |
---|---|---|
model_name |
str
|
Name of the model (e.g. 'flex_20M', 'flash_10M'). |
epoch |
str
|
Epoch number as string (e.g. 'epoch=20'). |
variant_base |
str
|
Base variant string (e.g. 'b50_sm_st_ea=1_da=1'). |
true_reacs |
bool
|
Whether to use true reactions. |
stock |
bool
|
Whether to use stock compounds. |
ds_name |
str
|
Dataset name (e.g. 'n1', 'n5'). |
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
correct_paths_name: str
property
Get the name of the correct paths file.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Correct paths file name. |
display_name: str
property
Generate display name from model name.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Display name of the model. |
processed_paths_name: str
property
Get the name of the processed paths file.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Processed paths file name. |
save_suffix: str
property
Get the name of the save file.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Save file suffix. |
variant: str
property
Get the full variant string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Full variant string. |
get_result_path(eval_path)
Get the path to the results directory for this config.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
eval_path
|
Path
|
Path to the evaluation directory. |
required |
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
Path to the results directory. |
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
with_dataset(ds_name)
Create a new config with dataset information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ds_name
|
str
|
Dataset name. |
required |
Returns:
Name | Type | Description |
---|---|---|
ModelPlotConfig |
ModelPlotConfig
|
New config with dataset information. |
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
RouteAnalyzer
Analyzes predicted routes and calculates various statistics.
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 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 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
|
__init__(predicted_routes, true_routes, k_vals=None)
Initializes the RouteAnalyzer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predicted_routes
|
PathsProcessedType
|
Predicted routes. |
required |
true_routes
|
list[str]
|
True routes. |
required |
k_vals
|
list[int] | None
|
List of k values for top-k accuracy calculation. |
None
|
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
analyze_and_log_results()
Run full analysis and log results.
Returns:
Type | Description |
---|---|
dict[str, dict[str, str]]
|
dict[str, dict[str, str]]: Dictionary of top-k accuracies. |
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
analyze_convergence_stats()
Analyze and log basic convergence statistics.
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
calculate_top_k_accuracies(save_path=None)
Calculate top-k accuracies for different route subsets and optionally save results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
save_path
|
Path | None
|
Optional path to save detailed accuracies to YAML file. |
None
|
Returns:
Type | Description |
---|---|
dict[str, dict[str, str]]
|
dict[str, dict[str, str]]: Dictionary of top-k accuracies. |
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
create_accuracy_by_length_plot(result_paths, datasets, configs, k_vals, title='')
staticmethod
Create plot showing accuracy by route length.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result_paths
|
list[Path]
|
List of paths to result directories. |
required |
datasets
|
list[DatasetDict]
|
List of datasets to analyze. |
required |
configs
|
list[ModelPlotConfig]
|
List of model configurations. |
required |
k_vals
|
list[int]
|
List of k values to calculate accuracy for. |
required |
title
|
str
|
Title for the plot. |
''
|
Returns:
Type | Description |
---|---|
Figure
|
go.Figure: Plotly figure object. |
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
create_accuracy_by_length_subplots(result_paths, datasets, configs, k_vals, title='')
staticmethod
Create plot showing accuracy by route length with subplots for all/convergent/non-convergent routes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result_paths
|
list[Path]
|
List of paths to result directories. |
required |
datasets
|
list[DatasetDict]
|
List of datasets to analyze. |
required |
configs
|
list[ModelPlotConfig]
|
List of model configurations. |
required |
k_vals
|
list[int]
|
List of k values to calculate accuracy for. |
required |
title
|
str
|
Title for the plot. |
''
|
Returns:
Type | Description |
---|---|
Figure
|
go.Figure: Plotly figure object. |
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
create_comparative_bar_plots(result_paths, trace_names, k_vals=None, title='')
staticmethod
Create comparative bar plots showing top-k accuracy for different configurations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result_paths
|
list[Path]
|
List of paths to top_k_accuracy_detailed.yaml files. |
required |
trace_names
|
list[str]
|
List of names for each trace (must match length of result_paths). |
required |
k_vals
|
list[int] | None
|
Optional list of k values to show. If None, shows all k values. |
None
|
title
|
str
|
Title for the plot. |
''
|
Returns:
Type | Description |
---|---|
Figure
|
go.Figure: Plotly figure object. |
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
visualize_route_distributions(dataset_name='')
Create a publication-quality figure showing the distribution of predicted routes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name
|
str
|
Name of the dataset being analyzed, used in plot title. |
''
|
Returns:
Type | Description |
---|---|
Figure
|
go.Figure: Plotly figure object. |
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
visualize_route_processing_stages(valid_routes, processed_routes_no_stock, processed_routes_with_stock, true_routes, dataset_name='', show_filtered_stats=False)
staticmethod
Create a publication-quality figure showing the distribution of routes at different processing stages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
valid_routes
|
PathsProcessedType
|
Valid routes from beam search. |
required |
processed_routes_no_stock
|
PathsProcessedType
|
Routes after canonicalization/removing repetitions. |
required |
processed_routes_with_stock
|
PathsProcessedType
|
Routes after applying stock filter. |
required |
true_routes
|
list[str]
|
True routes for convergence analysis. |
required |
dataset_name
|
str
|
Name of the dataset being analyzed. |
''
|
show_filtered_stats
|
bool
|
Whether to show filtered statistics (mean and median). |
False
|
Returns:
Type | Description |
---|---|
Figure
|
go.Figure: Plotly figure object. |
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
|
calculate_prediction_stats(predictions)
Calculate mean and median statistics for a list of predictions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predictions
|
list[int]
|
List of prediction counts. |
required |
Returns:
Type | Description |
---|---|
float
|
Tuple of (mean, median, filtered_mean, filtered_median) where filtered |
float
|
versions only consider predictions with count > 0. |
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
get_convergent_indices(path_strings)
Identify indices of convergent routes in dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_strings
|
list[str]
|
List of path strings. |
required |
Returns:
Type | Description |
---|---|
set[int]
|
set[int]: Set of indices of convergent routes. |
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
load_predicted_routes(path)
Load predicted routes from a pickle file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path to the pickle file. |
required |
Returns:
Name | Type | Description |
---|---|---|
PathsProcessedType |
PathsProcessedType
|
Loaded predicted routes. |
Source code in src/directmultistep/analysis/paper/linear_vs_convergent.py
process_model_configs(eval_path, configs, dataset)
Process model configurations and ensure top-k accuracies are calculated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
eval_path
|
Path
|
Path to evaluation directory. |
required |
configs
|
list[ModelPlotConfig]
|
List of model configurations. |
required |
dataset
|
DatasetDict
|
Dataset to process. |
required |
Returns:
Type | Description |
---|---|
tuple[list[Path], list[str]]
|
Tuple of (result_paths, trace_names) for plotting. |