Skip to content

Commit

Permalink
Merge pull request #3 from psaegert/dev
Browse files Browse the repository at this point in the history
Analysis Notebooks
  • Loading branch information
psaegert authored Dec 13, 2024
2 parents ff9355f + 54b8b84 commit e1f55ff
Show file tree
Hide file tree
Showing 153 changed files with 10,064 additions and 3,692 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ flash_ansr evaluate -c {{ROOT}}/configs/${CONFIG}/evaluation.yaml -m "{{ROOT}}/m
flash_ansr evaluate -c {{ROOT}}/configs/${CONFIG}/evaluation.yaml -m "{{ROOT}}/models/ansr-models/${MODEL}" -d "{{ROOT}}/data/ansr-data/test_set/feynman/dataset.yaml" -n 5000 -o {{ROOT}}/results/evaluation/${CONFIG}/feynman.pickle -v
flash_ansr evaluate -c {{ROOT}}/configs/${CONFIG}/evaluation.yaml -m "{{ROOT}}/models/ansr-models/${MODEL}" -d "{{ROOT}}/data/ansr-data/test_set/nguyen/dataset.yaml" -n 5000 -o {{ROOT}}/results/evaluation/${CONFIG}/nguyen.pickle -v
flash_ansr evaluate -c {{ROOT}}/configs/${CONFIG}/evaluation.yaml -m "{{ROOT}}/models/ansr-models/${MODEL}" -d "{{ROOT}}/configs/${CONFIG}/dataset_val.yaml" -n 5000 -o {{ROOT}}/results/evaluation/${CONFIG}/val.pickle -v
flash_ansr evaluate -c {{ROOT}}/configs/${CONFIG}/evaluation.yaml -m "{{ROOT}}/models/ansr-models/${MODEL}" -d "{{ROOT}}/data/ansr-data/test_set/hard_set/dataset.yaml" -n 5000 -o {{ROOT}}/results/evaluation/${CONFIG}/hard_set.pickle -v
flash_ansr evaluate -c {{ROOT}}/configs/${CONFIG}/evaluation.yaml -m "{{ROOT}}/models/ansr-models/${MODEL}" -d "{{ROOT}}/data/ansr-data/test_set/pool_15/dataset.yaml" -n 5000 -o {{ROOT}}/results/evaluation/${CONFIG}/pool_15.pickle -v
flash_ansr evaluate -c {{ROOT}}/configs/${CONFIG}/evaluation.yaml -m "{{ROOT}}/models/ansr-models/${MODEL}" -d "{{ROOT}}/configs/${CONFIG}/dataset_train.yaml" -n 5000 -o {{ROOT}}/results/evaluation/${CONFIG}/train.pickle -v
```

Expand All @@ -204,15 +204,16 @@ with
#### 4.1 Evaluate NeSymRes
1. Clone [NeuralSymbolicRegressionThatScales](https://github.com/SymposiumOrganization/NeuralSymbolicRegressionThatScales) to a directory of your choice.
2. Download the `100M` model as described [here](https://github.com/SymposiumOrganization/NeuralSymbolicRegressionThatScales?tab=readme-ov-file#pretrained-models)
3. Create a Python 3.10 (!) environment and install flash-ansr as in the previous steps.
4. Install NeSymRes in the same environment:
3. Move the `100M` model into `flash-ansr/models/nesymres/`
4. Create a Python 3.10 (!) environment and install flash-ansr as in the previous steps.
5. Install NeSymRes in the same environment:
```sh
cd NeuralSymbolicRegressionThatScales
pip install -e src/
```
5. Navigate back to this repository and run the evaluation
1. Navigate back to this repository and run the evaluation
```sh
cd ansr
cd flash-ansr
./scripts/evaluate_nesymres <test_set>
```

Expand Down
2 changes: 2 additions & 0 deletions configs/analysis_beams/v6.0_1-beams/dataset_train.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skeleton_pool: './skeleton_pool_train.yaml'
padding: 'zero'
2 changes: 2 additions & 0 deletions configs/analysis_beams/v6.0_1-beams/dataset_val.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skeleton_pool: './skeleton_pool_val.yaml'
padding: 'zero'
13 changes: 13 additions & 0 deletions configs/analysis_beams/v6.0_1-beams/evaluation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
n_support: 512
beam_width: 1
n_restarts: 8
max_len: 32
numeric_head: False
equivalence_pruning: True
pointwise_close_criterion: 0.95
pointwise_close_accuracy_rtol: 0.05
pointwise_close_accuracy_atol: 0.001
r2_close_criterion: 0.95
refiner_p0_noise: 'uniform'
refiner_p0_noise_kwargs: {'low': -5, 'high': 5}
device: cuda
267 changes: 267 additions & 0 deletions configs/analysis_beams/v6.0_1-beams/expression_space.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
operators:
"+":
realization: "+"
alias: ["add", "plus"]
inverse: "-"
arity: 2
weight: 10
precedence: 1
commutative: true
symmetry: 0
positive: false
monotonicity: 0
"-":
realization: "-"
alias: ["sub", "minus"]
inverse: "+"
arity: 2
weight: 5
precedence: 1
commutative: false
symmetry: 0
positive: false
monotonicity: 0
neg:
realization: "nsrops.neg"
wolfram: "Negative"
alias: ["negative"]
inverse: "neg"
arity: 1
weight: 5
precedence: 2.5
commutative: false
symmetry: -1 # anti-symmetric
positive: false
monotonicity: -1
"*":
realization: "*"
alias: ["mul", "times"]
inverse: "/"
arity: 2
weight: 10
precedence: 2
commutative: true
symmetry: 0
positive: false
monotonicity: 0
"/":
realization: "/"
alias: ["div", "divide"]
inverse: "*"
arity: 2
weight: 5
precedence: 2
commutative: false
symmetry: 0
positive: false
monotonicity: 0
abs:
realization: "abs"
wolfram: "Abs"
alias: ["absolute"]
inverse: null
arity: 1
weight: 4
precedence: 3
commutative: false
symmetry: 1 # symmetric
positive: true
monotonicity: 0
inv:
realization: "nsrops.inv"
wolfram: "Inverse"
alias: ["inverse"]
inverse: "inv"
arity: 1
weight: 4
precedence: 4
commutative: false
symmetry: -1 # anti-symmetric
positive: false
monotonicity: -1
pow2:
realization: "nsrops.pow2"
alias: ["square"]
inverse: null
arity: 1
weight: 4
precedence: 3
commutative: false
symmetry: 1 # symmetric
positive: true
monotonicity: 0
pow3:
realization: "nsrops.pow3"
alias: ["cube"]
inverse: "pow1_3"
arity: 1
weight: 2
precedence: 3
commutative: false
symmetry: -1 # anti-symmetric
positive: false
monotonicity: 1
pow4:
realization: "nsrops.pow4"
alias: []
inverse: null
arity: 1
weight: 1
precedence: 3
commutative: false
symmetry: 1
positive: true
monotonicity: 0
pow5:
realization: "nsrops.pow5"
alias: []
inverse: "pow1_5"
arity: 1
weight: 1
precedence: 3
commutative: false
symmetry: -1 # anti-symmetric
positive: false
monotonicity: 1
pow1_2:
realization: "nsrops.pow1_2"
alias: ["sqrt"]
inverse: null
arity: 1
weight: 4
precedence: 3
commutative: false
symmetry: 0
positive: true
monotonicity: 1
pow1_3:
realization: "nsrops.pow1_3"
alias: []
inverse: null
arity: 1
weight: 2
precedence: 3
commutative: false
symmetry: -1 # anti-symmetric
positive: false
monotonicity: 1
pow1_4:
realization: "nsrops.pow1_4"
alias: []
inverse: null
arity: 1
weight: 1
precedence: 3
commutative: false
symmetry: 0
positive: true
monotonicity: 1
pow1_5:
realization: "nsrops.pow1_5"
alias: []
inverse: null
arity: 1
weight: 1
precedence: 3
commutative: false
symmetry: -1 # anti-symmetric
positive: false
monotonicity: 1
sin:
realization: "numpy.sin"
wolfram: "Sin"
alias: []
inverse: "asin"
arity: 1
weight: 4
precedence: 2
commutative: false
symmetry: -1 # anti-symmetric
positive: false
monotonicity: 0
cos:
realization: "numpy.cos"
wolfram: "Cos"
alias: []
inverse: "acos"
arity: 1
weight: 4
precedence: 2
commutative: false
symmetry: 1 # symmetric
positive: false
monotonicity: 0
tan:
realization: "numpy.tan"
wolfram: "Tan"
alias: []
inverse: "atan"
arity: 1
weight: 4
precedence: 2
commutative: false
symmetry: -1 # anti-symmetric
positive: false
monotonicity: 0
asin:
realization: "numpy.arcsin"
wolfram: "ArcSin"
alias: ["arcsin"]
inverse: "sin"
arity: 1
weight: 2
precedence: 2
commutative: false
symmetry: -1 # anti-symmetric
positive: false
monotonicity: 1
acos:
realization: "numpy.arccos"
wolfram: "ArcCos"
alias: ["arccos"]
inverse: "cos"
arity: 1
weight: 2
precedence: 2
commutative: false
symmetry: 0
positive: true
monotonicity: 1
atan:
realization: "numpy.arctan"
wolfram: "ArcTan"
alias: ["arctan"]
inverse: "tan"
arity: 1
weight: 2
precedence: 2
commutative: false
symmetry: -1 # anti-symmetric
positive: false
monotonicity: 1
exp:
realization: "numpy.exp"
wolfram: "Exp"
alias: []
inverse: "log"
arity: 1
weight: 4
precedence: 3
commutative: false
symmetry: 0
positive: true
monotonicity: 1
log:
realization: "numpy.log"
wolfram: "Log"
alias: ["ln"]
inverse: "exp"
arity: 1
weight: 4
precedence: 2
commutative: false
symmetry: 0
positive: false
monotonicity: 1

variables: 3
25 changes: 25 additions & 0 deletions configs/analysis_beams/v6.0_1-beams/nsr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
encoder_max_n_variables: 4 # includes the dependent variable
size: 512

pre_encoder_input_type: "ieee-754"
pre_encoder_support_nan: False

encoder: "SetTransformer"
encoder_kwargs:
hidden_size: 512
n_enc_isab: 5
n_dec_sab: 2
n_induce: 64
n_heads: 8
layer_norm: False
n_seeds: 64

decoder_n_heads: 8
decoder_ff_size: 512
decoder_dropout: 0.1
decoder_n_layers: 5

learnable_positional_embeddings: false
max_input_length: null

expression_space: './expression_space.yaml'
37 changes: 37 additions & 0 deletions configs/analysis_beams/v6.0_1-beams/skeleton_pool_train.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
expression_space: './expression_space.yaml'
holdout_pools: [
"{{ROOT}}/data/ansr-data/v6.0/skeleton_pool_val/",
"{{ROOT}}/data/ansr-data/test_set/soose_nc/skeleton_pool/",
"{{ROOT}}/data/ansr-data/test_set/feynman/skeleton_pool/",
"{{ROOT}}/data/ansr-data/test_set/nguyen/skeleton_pool/",
"{{ROOT}}/data/ansr-data/test_set/pool_15/skeleton_pool/"
]

sample_strategy:
n_operator_distribution: "length_proportional"
min_operators: 0
max_operators: 10
power: 1
max_length: 21
max_tries: 1
independent_dimensions: True

allow_nan: False
simplify: True

literal_prior: 'uniform'
literal_prior_kwargs:
low: -5
high: 5

support_prior: "uniform_intervals"
support_prior_kwargs:
low: -10
high: 10

n_support_prior: "uniform"
n_support_prior_kwargs:
low: 16
high: 512
min_value: 16
max_value: 512
Loading

0 comments on commit e1f55ff

Please sign in to comment.