Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PySRSequenceRegressor #677

Open
wants to merge 198 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 181 commits
Commits
Show all changes
198 commits
Select commit Hold shift + click to select a range
b9865b0
Added recursive_history_length
wenbang24 Jul 21, 2024
1ce85fe
Changed minimum recursive history length
wenbang24 Jul 21, 2024
f46e4d2
fixed syntax error
wenbang24 Jul 21, 2024
0cbdcda
Added recurrence functionality
wenbang24 Jul 21, 2024
7172cc7
Removed a debug print, also formatted
wenbang24 Jul 21, 2024
ff1944c
new PySRSequenceRegressor class!
wenbang24 Jul 23, 2024
4072729
made recursive_history_length not optional
wenbang24 Jul 23, 2024
8ab384a
added tests for PySRSequenceRegressor
wenbang24 Jul 23, 2024
cffcc91
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 23, 2024
e91dc68
changed __init__ of PySRSequenceRegressor to use PySRRegressor's __in…
wenbang24 Jul 23, 2024
f0d6ecf
fixed bug that removed first data point
wenbang24 Jul 23, 2024
7db3df8
added sequence to test names to make things a bit clearer
wenbang24 Jul 23, 2024
506f4f5
added .eggs to .gitignore
wenbang24 Jul 23, 2024
d556d11
Merge branch 'recurrence' into wenbang24/issue94
wenbang24 Jul 23, 2024
fc86554
Merge pull request #1 from wenbang24/wenbang24/issue94
wenbang24 Jul 23, 2024
962e0a9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 23, 2024
87ad4d9
updated docstring for PySRSequenceRegressor
wenbang24 Jul 24, 2024
75ea04d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 24, 2024
365e663
updated fit()
wenbang24 Jul 24, 2024
ed61b3c
multidimensionality!!!
wenbang24 Jul 24, 2024
f10b6ca
fixed variable names for multidimensionality
wenbang24 Jul 24, 2024
518e7d8
fixed variable names
wenbang24 Jul 24, 2024
510d5d0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 24, 2024
cbc9105
git is hard
wenbang24 Jul 24, 2024
8f0c730
added new preprocessing to predict
wenbang24 Jul 24, 2024
c3d5aa5
Merge branch 'recurrence' of github.com:wenbang24/PySR into recurrence
wenbang24 Jul 24, 2024
908fdfc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 24, 2024
666b2a8
removed unecessary test
wenbang24 Jul 24, 2024
f78cb44
small documentaion change
wenbang24 Jul 25, 2024
d8b8245
didn't the last commit work?
wenbang24 Jul 25, 2024
c6b67d6
another small doc change
wenbang24 Jul 25, 2024
a4f607e
ok the preprocessing ACTUALLY works now
wenbang24 Jul 25, 2024
9927660
fixed custom variable names
wenbang24 Jul 25, 2024
de74c47
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 25, 2024
62cf992
updated tests
wenbang24 Jul 25, 2024
27c73e7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 25, 2024
b3e303e
all tests passing!!!
wenbang24 Jul 25, 2024
92f2a40
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 25, 2024
94eabe3
refactor: moved PySRSequenceRegressor to ssr.py
wenbang24 Jul 25, 2024
aca4672
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 25, 2024
089c565
slight change in multidimensional data error test
wenbang24 Jul 28, 2024
b47172c
made the type checking work, added tests for unused variables
wenbang24 Jul 28, 2024
a3c63c8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 28, 2024
ba1ce25
yeah the override decorator wasn't needed
wenbang24 Jul 28, 2024
a9019a7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 28, 2024
7bdd41a
this test is too harsh
wenbang24 Jul 28, 2024
a88e725
swap super.__init__ and other thing in __init__
wenbang24 Jul 28, 2024
aa42888
now needs numpy 1.20
wenbang24 Jul 28, 2024
307261b
changed predict docstring
wenbang24 Jul 28, 2024
14331e1
change test sequence name
wenbang24 Jul 28, 2024
9eb54b3
change multidimensional data error test
wenbang24 Jul 28, 2024
df26237
renamed ssr.py to regressor_sequence.py
wenbang24 Jul 29, 2024
bca7cc9
moved assertions to new function, fixed error in variable name genera…
wenbang24 Jul 29, 2024
34e449b
removed need for temp
wenbang24 Jul 29, 2024
38edd3d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 29, 2024
96ea494
changed variable names and made target generation a bit more efficient
wenbang24 Jul 29, 2024
1a29161
made predict use _check_assertions as well
wenbang24 Jul 29, 2024
854edc7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 29, 2024
5213cc8
moved variable name generation to new function and also added variabl…
wenbang24 Jul 29, 2024
925783c
remove unnecessary test
wenbang24 Jul 29, 2024
1a45b90
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 29, 2024
d0ff80d
made unused variables throw errors
wenbang24 Jul 29, 2024
b449772
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 29, 2024
3dc1fd4
changed check_assertions to have no return value
wenbang24 Jul 29, 2024
709ff56
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 29, 2024
ff126c2
removed unecessary tests
wenbang24 Jul 29, 2024
484c836
changed up variable names
wenbang24 Jul 29, 2024
518df7d
fixed up check_assertions in predict
wenbang24 Jul 29, 2024
31c6bb6
fixed bug in variable name generation
wenbang24 Jul 29, 2024
12d3e82
fixed bug in assertion checking in predict
wenbang24 Jul 29, 2024
edab12f
changed up variable names
wenbang24 Jul 29, 2024
0354818
changed name of variable name generator
wenbang24 Jul 30, 2024
03beb0e
changed variable name generator to take n_features
wenbang24 Jul 30, 2024
8e4b664
Updated docstring
wenbang24 Jul 30, 2024
e170496
added validation of X
wenbang24 Jul 30, 2024
10f26c7
added another validation
wenbang24 Jul 30, 2024
ff75b07
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 30, 2024
e5ed5c5
added doc string for PySRSymbolicRegressor
wenbang24 Jul 30, 2024
be64ee3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 30, 2024
ceb58ff
changed variable name generation function to isinstance rather than t…
wenbang24 Jul 30, 2024
e3d19f2
think i fixed predicting shape
wenbang24 Jul 30, 2024
9721b8f
changed PySRSequenceRegressor to inherit from BaseEstimator and have …
wenbang24 Jul 30, 2024
eb796c7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 30, 2024
8549d8c
padding with NaNs does not work
wenbang24 Jul 30, 2024
a450abb
made extrapolating when prredicting work :)
wenbang24 Jul 30, 2024
15be253
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 30, 2024
4656585
updated dosctring to have extra_preditciotns
wenbang24 Jul 30, 2024
12ba70f
tried delegation but this doesn't work
wenbang24 Aug 1, 2024
c0ec717
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 1, 2024
de14be6
forwarded all methods and properties from PySRRegressor to PySRSequec…
wenbang24 Aug 2, 2024
4c362f9
finally fixed the bug in variable name test
wenbang24 Aug 6, 2024
433f783
removed unecessary variables
wenbang24 Aug 6, 2024
ef26021
updated docstring
wenbang24 Aug 6, 2024
8dcd625
added __getstate__ to PySRSequenceRegressor
wenbang24 Aug 6, 2024
7846199
update docstring
wenbang24 Aug 6, 2024
b3a45e8
added super().__init()
wenbang24 Aug 6, 2024
1eda1a3
removed n_features_in
wenbang24 Aug 6, 2024
a2d2821
example.py is back
wenbang24 Aug 6, 2024
feab3e4
variable names for unnamed 1D sequences work now
wenbang24 Aug 6, 2024
bad23cb
latex table no longer says y, but xt_0 (or whatever the variable name…
wenbang24 Aug 7, 2024
57233b3
added docstring for complexity of variables
wenbang24 Aug 7, 2024
a35e136
grammar is hard
wenbang24 Aug 7, 2024
b037e86
remove unused imports
wenbang24 Aug 7, 2024
d08b77b
uncomment tests
wenbang24 Aug 7, 2024
d7f15f8
newlines??
wenbang24 Aug 7, 2024
cd04146
put a comment back
wenbang24 Aug 7, 2024
64d30b8
new inherits
wenbang24 Aug 8, 2024
164a399
remove y units
wenbang24 Aug 8, 2024
6ec0d2a
remove show pickel warnings
wenbang24 Aug 8, 2024
208de79
removed a lot of unneccesary properties
wenbang24 Aug 8, 2024
b52a221
removed __getstate__
wenbang24 Aug 8, 2024
9c6326c
removed some commmented out code
wenbang24 Aug 8, 2024
59555eb
since recursive history length >= 1, we don't need to test for len(X)…
wenbang24 Aug 9, 2024
ba3b538
more tests
wenbang24 Aug 9, 2024
4de8ec9
update dosctring
wenbang24 Aug 9, 2024
5bd6898
more tests
wenbang24 Aug 9, 2024
5db1096
more tests
wenbang24 Aug 9, 2024
029633a
Merge branch 'master' into recurrence
wenbang24 Aug 10, 2024
2341c74
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 10, 2024
7ae96a2
ok i think from_file works now
wenbang24 Aug 10, 2024
1f9013f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 10, 2024
427ac6b
so i think we need to pickle recursive history length :(
wenbang24 Aug 10, 2024
263912e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 10, 2024
1b79dd9
remove debug print
wenbang24 Aug 10, 2024
16cad6e
ok fromfile actually works now
wenbang24 Aug 10, 2024
689d717
added weight test
wenbang24 Aug 10, 2024
4a1f17c
added feature name and selection mask tests
wenbang24 Aug 10, 2024
1ef2fc6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 10, 2024
1fe3fe3
add recursive history length parameter
wenbang24 Aug 10, 2024
39cab90
fixed typing for variable names in fit
wenbang24 Aug 10, 2024
a734b48
removed julia properties
wenbang24 Aug 13, 2024
bff3ef3
changed from_file to use PySRRegressor's from_file
wenbang24 Aug 13, 2024
4c5e9e9
removed uncessary line
wenbang24 Aug 13, 2024
0459cf4
moved args???
wenbang24 Aug 13, 2024
424483b
a lot of **kwargs
wenbang24 Aug 13, 2024
3b1acb2
removed super().__init__()
wenbang24 Aug 13, 2024
06ee369
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 13, 2024
9b5a2c0
updated numpy to 1.20 in environment.yml
wenbang24 Aug 13, 2024
0e55024
changed __repr__ to only change first instance
wenbang24 Aug 13, 2024
1632e89
updated latex_table to use PySRRegressor's latex_table, also added ou…
wenbang24 Aug 13, 2024
43dd918
removed MultiOutputMixin, RegressorMixin
wenbang24 Aug 13, 2024
6e7166d
fixed bug with output_variable_names
wenbang24 Aug 13, 2024
e77d56f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 13, 2024
1bd482c
Merge branch 'master' into recurrence
wenbang24 Aug 13, 2024
fa1e2f2
add back super().__init__()
wenbang24 Aug 15, 2024
a569b2e
stars and stuff
wenbang24 Aug 15, 2024
8ab243a
another star
wenbang24 Aug 15, 2024
9010fbe
remove unused imports
wenbang24 Aug 15, 2024
f395db4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 15, 2024
a745b19
refactor: moved np.lib.stride_tricks.sliding_window_view out to anoth…
wenbang24 Aug 15, 2024
102e453
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 15, 2024
e75a8bc
Merge branch 'master' into recurrence
wenbang24 Aug 15, 2024
ef03dff
update doctoring
wenbang24 Aug 15, 2024
8e29d92
update docstring for weights
wenbang24 Aug 15, 2024
5aff022
rewrote extra predictions in predict() to use num_predictions
wenbang24 Aug 16, 2024
92287b1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 16, 2024
c854788
fixed predicting and changed up tests
wenbang24 Aug 16, 2024
6eb7920
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 16, 2024
5407157
removed comments
wenbang24 Aug 16, 2024
f634dae
updated docstring
wenbang24 Aug 17, 2024
dbcc918
updated docstring to remove y
wenbang24 Aug 17, 2024
378f05b
Update docstring formatting
wenbang24 Aug 24, 2024
a4a2fda
added a lot of *args
wenbang24 Aug 24, 2024
5d7d4e6
Update predict docstring to add num_predictions times
wenbang24 Aug 24, 2024
206ee98
fix error in predict docstring
wenbang24 Aug 24, 2024
0a926ac
remove default in docstring
wenbang24 Aug 24, 2024
56a7780
add default to predict docstring somewhere else
wenbang24 Aug 24, 2024
96c7a35
Merge branch 'master' into recurrence
wenbang24 Aug 24, 2024
d3d4fd0
added args to latex_table
wenbang24 Aug 24, 2024
0c9515e
changed variable name format
wenbang24 Aug 24, 2024
66542ff
feat: allow 1D input
MilesCranmer Aug 26, 2024
63e7785
Update pysr/regressor_sequence.py
MilesCranmer Aug 26, 2024
516e4e6
feat: pretty-print sequence index
MilesCranmer Aug 26, 2024
163128e
sequence example
wenbang24 Aug 28, 2024
9299df4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 28, 2024
6fba3d7
update sequence example
wenbang24 Aug 28, 2024
6cee114
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 28, 2024
055bec6
added markdown example docs
wenbang24 Aug 29, 2024
9ee3018
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 29, 2024
43049e1
removed example sequence file
wenbang24 Aug 29, 2024
93337d3
removed some miskates in examples sequence
wenbang24 Aug 29, 2024
e842784
updated example sequence
wenbang24 Aug 29, 2024
d984850
moved sequence examples to examples.md
wenbang24 Aug 29, 2024
25d9905
updated latex_table to use _t instead of _{t-0}
wenbang24 Aug 29, 2024
5c360b0
updated latex_table docstring to refer to PySRRegressor.latex_table
wenbang24 Aug 29, 2024
ec5d941
updated examples to not have X = np.array(X)
wenbang24 Aug 29, 2024
84acd0c
updated docs to use latex
wenbang24 Aug 29, 2024
2d1becb
removed warning if num_predictions < len(historical_X)
wenbang24 Aug 29, 2024
371e0ac
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 29, 2024
abe556e
updated tests for new variable names
wenbang24 Aug 29, 2024
e23ccfd
missed a few
wenbang24 Aug 29, 2024
8c285e9
ok all working now
wenbang24 Aug 29, 2024
9263837
whoops forgot to remove commetns
wenbang24 Aug 29, 2024
7f16257
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 29, 2024
fc6eaf1
fixed a test in TestDimensionalConstraints
wenbang24 Aug 29, 2024
5b4993b
removed unecessary print
wenbang24 Sep 2, 2024
4d69542
fix typing with a cast
wenbang24 Sep 3, 2024
9aecee8
Merge branch 'master' into recurrence
wenbang24 Oct 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ site
venv
requirements-dev.lock
requirements.lock
.eggs/
52 changes: 52 additions & 0 deletions docs/examples_sequence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Toy Sequence Examples with Code
wenbang24 marked this conversation as resolved.
Show resolved Hide resolved

## Preamble
```python
import numpy as np
from pysr import PySRSequenceRegressor
```

Note that most of the functionality
of PySRSequenceRegressor is inherited
from PySRRegressor.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should link the docs pages using the mkdocs functionality to build references

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which page should it be linked to?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok for now i linked it to options.md, wdyt?


## 1. Simple Search

Here's a simple example where we
find the expression `f(n) = f(n-1) + f(n-2)`.

```python
X = [1, 1]
for i in range(20):
X.append(X[-1] + X[-2])
X = np.array(X)
wenbang24 marked this conversation as resolved.
Show resolved Hide resolved
model = PySRSequenceRegressor(
recursive_history_length=2,
binary_operators=["+", "-", "*", "/"]
)
model.fit(X) # no y needed
print(model)
```

## 2. Multidimensionality

Here we find a 2D recurrence relation
with two data points at a time.
wenbang24 marked this conversation as resolved.
Show resolved Hide resolved

```python
X = [[1, 2], [3, 4]]
for i in range(100):
X.append([
X[-1][0] + X[-2][0],
X[-1][1] - X[-2][1]
])
X = np.array(X)
wenbang24 marked this conversation as resolved.
Show resolved Hide resolved

model = PySRSequenceRegressor(
recursive_history_length=2,
binary_operators=["+", "*"],
)

model.fit(X)
print(model)
```
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dependencies:
- python>=3.8
- sympy>=1.0.0,<2.0.0
- pandas>=0.21.0,<3.0.0
- numpy>=1.13.0,<2.0.0
- numpy>=1.20.0,<2.0.0
- scikit-learn>=1.0.0,<2.0.0
- pyjuliacall>=0.9.21,<0.9.22
- click>=7.0.0,<9.0.0
2 changes: 2 additions & 0 deletions pysr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .export_jax import sympy2jax
from .export_torch import sympy2torch
from .julia_extensions import load_all_packages
from .regressor_sequence import PySRSequenceRegressor
from .sr import PySRRegressor

# This file is created by setuptools_scm during the build process:
Expand All @@ -22,6 +23,7 @@
"install",
"load_all_packages",
"PySRRegressor",
"PySRSequenceRegressor",
"best",
"best_callable",
"best_row",
Expand Down
3 changes: 3 additions & 0 deletions pysr/export_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def sympy2latextable(
if indices is None:
indices = list(equations.index)

if output_variable_name == None:
output_variable_name = "y"

for i in indices:
latex_equation = sympy2latex(
equations.iloc[i]["sympy_format"],
Expand Down
Loading