Why doesn't it work like the video?
heimawsw opened this issue · 5 comments
Hi @heimawsw,
PhySO is a symbolic regression package aiming at discovering physical laws from datasets.
The screenshot that you sent is the output of the units tests, not a proper symbolic regression task on a dataset.
You should run the damped harmonic oscillator notebook, it will output a live monitoring plot + a log that will contain an even more informative record of what's going on during the symbolic regression task than the video did.
I see it in the log
sin(((phi+((((((((t*f))(2)))(-1)))**(2))-exp(-(phi))))+phi))
This expression, can this expression be converted into a formula? In what way?
Hi @heimawsw,
To convert an expression in the log into a more good looking latex expression, you can use this snippet:
import sympy
import matplotlib.pyplot as plt
expr_str = "(sin(((f*t)+phi))*exp((alpha*-(t))))+1-1"
# Getting a sympy expression
expr_sympy = sympy.parsing.sympy_parser.parse_expr(expr_str, evaluate=False)
# If you want the simplified version
expr_sympy = sympy.simplify(expr_sympy, rational=True)
# Getting a latex expression
expr_latex = sympy.latex (expr_sympy)
# Getting a figure containing expression
#plt.rc('text', usetex=True)
#plt.rc('font', family='serif')
#plt.rc('text.latex', preamble=r'\usepackage{amssymb} \usepackage{xcolor}')
fig, ax = plt.subplots(1, 1, figsize=(10, 2))
ax.axis('off')
text_pos = (0.0, 0.5)
ax.text(text_pos[0], text_pos[1], f'${expr_latex}$', size = 16)
plt.show()
That's what I used to make the demo video !
Thank you very much for the ideas provided by the author, I am now successfully running python as expected. In the future, I will learn how to optimize machine learning time. Currently, data processing is very slow.