Export#
Export of equations to code, documents and model-exchange formats.
A discovered equation is most useful where it runs: in a control system, a spreadsheet, a simulator or a database. This module writes it as
source code – Python (
mathor NumPy), C, MATLAB/Octave, Julia;an Excel formula over cell references;
LaTeX and SymPy;
PMML 4.4 (a
DerivedFieldbuilt fromApplyelements and a regression model), readable by PMML scoring engines;JSON (lossless,
eqdisco.Equation.to_json()).
With protected=True (default) the code reproduces eqdisco’s protected
operators exactly (division by a near-zero value gives 1, logarithm and square
root of the absolute value, exponential clipped at \(e^{100}\)); with
protected=False the plain mathematical functions are written.
Examples#
>>> from eqdisco import Equation
>>> from eqdisco.export import to_python, to_excel
>>> eq = Equation.from_string("2.5*T*exp(-0.1*t)", feature_names=["T", "t"])
>>> print(to_python(eq, protected=False))
import math
def f(T, t):
return 2.5 * T * math.exp(-0.1 * t)
>>> to_excel(eq, {"T": "A2", "t": "B2"}, protected=False)
'=2.5*A2*EXP(-0.1*B2)'
Code generation (Python, NumPy, C, MATLAB, Julia, Excel, LaTeX) and PMML.
Functions#
|
Valid, unique identifiers for the variable names ( |
|
Python source ( |
|
A NumPy-vectorized callable |
|
C source of a function |
|
MATLAB/Octave function file (element-wise operators). |
|
Julia one-line function. |
|
Excel formula with the variables replaced by cell references ( |
|
LaTeX equation |
|
PMML 4.4 document of the equation. |
|
Source code of a function |