Spaces:
Running
Running
Download example.py from MilesCranmer/PySR: direct link, hf CLI and curl.
- Browser
- Download file 478 Bytes
-
https://huggingface.co/spaces/MilesCranmer/PySR/resolve/082d514b6f839595cdcbbc58225e613ded9f6e96/example.py
- Command line
-
hf download hf://spaces/MilesCranmer/PySR@082d514b6f839595cdcbbc58225e613ded9f6e96/example.py
-
curl -L -o example.py https://huggingface.co/spaces/MilesCranmer/PySR/resolve/082d514b6f839595cdcbbc58225e613ded9f6e96/example.py
478 Bytes
| import numpy as np | |
| X = 2 * np.random.randn(100, 5) | |
| y = 2.5382 * np.cos(X[:, 3]) + X[:, 0] ** 2 - 0.5 | |
| from pysr import PySRRegressor | |
| model = PySRRegressor( | |
| niterations=40, | |
| binary_operators=["+", "*"], | |
| unary_operators=[ | |
| "cos", | |
| "exp", | |
| "sin", | |
| "inv(x) = 1/x", # Custom operator (julia syntax) | |
| ], | |
| model_selection="best", | |
| loss="loss(x, y) = (x - y)^2", # Custom loss function (julia syntax) | |
| ) | |
| model.fit(X, y) | |
| print(model) | |