Spaces:
Running
Running
File size: 601 Bytes
1bd0408 90f5e4c 9dc8d8f 90f5e4c 1bd0408 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import numpy as np
from pysr import pysr, best
# Dataset
X = 2*np.random.randn(100, 5)
y = 2*np.cos(X[:, 3]) + X[:, 0]**2 - 2
# Learn equations
equations = pysr(X, y, niterations=5,
binary_operators=["plus", "mult"],
unary_operators=[
"cos", "exp", "sin", #Pre-defined library of operators (see https://pysr.readthedocs.io/en/latest/docs/operators/)
"inv(x) = 1/x"],
loss='loss(x, y) = abs(x - y)', # Custom loss function
julia_project="../SymbolicRegression.jl") # Define your own operator! (Julia syntax)
...# (you can use ctl-c to exit early)
print(best(equations))
|