ambrosys / glyph Goto Github PK
View Code? Open in Web Editor NEWa python 3 library based on deap providing abstraction layers for symbolic regression problems.
License: GNU Lesser General Public License v3.0
a python 3 library based on deap providing abstraction layers for symbolic regression problems.
License: GNU Lesser General Public License v3.0
The package description mentions "interfacing constant optimization to scipy.optimize", but we have trouble finding any further documentation on this. How can we make sure our constants are optimized?
Gooey is not going to use the callback functions, which were implemented.
They can be cleaned.
argparse non defaults > file/server > argsparse-defaults
Logging options should be loaded before gui, e.g. glyph-remote --gui -vvv
should enable debug logging to console to monitor gui startup.
hi,
Do you like AI? im sure many users and researchers and developers would appreciate the ability to apply genetic programming to neural networks / computation graphs... but i find support for this seemingly obvious idea to be really lacking in 2019. This looks like a cool project. I would like to use it, but if we can't hook it up to our existing tensorflow / keras stuff, it seems we can't use Glyph!
How hard do you think it would be to add tf.keras support to glyph so we could make computation graphs that run fast with tensorflow and have strongly typed / SHAPE CHECKING (to avoid infinity bugs and frustration) for tensors?
correct create_method nsga2 -> halfandhalf...
Add gui option --gui
for glyph-remote.
Installation of gui option should be optional, e.g. pip install "pyglyph[gui]"
Line 14 in 343a075
The cli should have a setter for the sent individual. Either one individual or a whole generation (or a certain number) shall be sent. this must be configurable.
This should finish the current generation, shut down communication and make a checkpoint.
After doing a clean checkout of the glyph github project, I'm getting below error on running the Lorenz example.
Python 3.6.4
<deap.gp.PrimitiveSet object at 0x1069be320>
Traceback (most recent call last):
File "examples/control/lorenz.py", line 137, in <module>
main()
File "examples/control/lorenz.py", line 78, in main
app.run()
File "/Users/bartolkaruza/dev/proj/uva/glyph/glyph/application.py", line 173, in run
self.gp_runner.init(self.args.pop_size)
File "/Users/bartolkaruza/dev/proj/uva/glyph/glyph/application.py", line 77, in init
self._update()
File "/Users/bartolkaruza/dev/proj/uva/glyph/glyph/application.py", line 87, in _update
self._evals = self.assessment_runner(self.population)
File "/Users/bartolkaruza/dev/proj/uva/glyph/glyph/assessment.py", line 53, in __call__
for ind, fit in zip(invalid, fitnesses):
File "examples/control/lorenz.py", line 47, in measure
popt, rmse_opt = assessment.const_opt_leastsq(self.rmse, individual)
File "/Users/bartolkaruza/dev/proj/uva/glyph/glyph/assessment.py", line 165, in const_opt_leastsq
return const_opt(measure, individual, lsq=True, default_constants=default_constants, f_kwargs=f_kwargs, **kwargs)
File "/Users/bartolkaruza/dev/proj/uva/glyph/glyph/assessment.py", line 152, in const_opt
res = opt(fun=closure, x0=p0, **kwargs)
File "/Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages/scipy/optimize/_lsq/least_squares.py", line 805, in least_squares
raise ValueError("Residuals are not finite in the initial point.")
ValueError: Residuals are not finite in the initial point.
Make init output
Bartols-MBP:glyph bartolkaruza$ make init
pip install -r requirements.txt
Requirement already satisfied: cache.py==0.1.3 in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from -r requirements.txt (line 8))
Collecting deap==1.0.2.post2 (from -r requirements.txt (line 9))
Using cached deap-1.0.2.post2.tar.gz
Requested deap==1.0.2.post2 from https://pypi.python.org/packages/5b/d7/a49d3dd7aa8cbaf2b1ac8f4d6495824c886fea8b3dac4a73dc4df94cad76/deap-1.0.2.post2.tar.gz#md5=ccf5ed7562e4d6236c9416e3b5a9d941 (from -r requirements.txt (line 9)), but installing version 1.0.2
Requirement already satisfied: dill==0.2.5 in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from -r requirements.txt (line 10))
Requirement already satisfied: joblib==0.11 in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from -r requirements.txt (line 11))
Requirement already satisfied: mpmath==0.19 in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from -r requirements.txt (line 12))
Requirement already satisfied: numpy==1.11.2 in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from -r requirements.txt (line 13))
Requirement already satisfied: pyyaml==3.12 in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from -r requirements.txt (line 14))
Requirement already satisfied: pyzmq==16.0.2 in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from -r requirements.txt (line 15))
Requirement already satisfied: scipy==0.19.0 in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from -r requirements.txt (line 16))
Requirement already satisfied: sqlitedict==1.5.0 in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from -r requirements.txt (line 17))
Requirement already satisfied: sympy==1.0 in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from -r requirements.txt (line 18))
Requirement already satisfied: toolz==0.8.1 in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from -r requirements.txt (line 19))
Installing collected packages: deap
Found existing installation: deap 1.0.2
Uninstalling deap-1.0.2:
Successfully uninstalled deap-1.0.2
Running setup.py install for deap ... done
Successfully installed deap-1.0.2
pip install -e .
Obtaining file:///Users/bartolkaruza/dev/proj/uva/glyph
Requirement already satisfied: deap in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from pyglyph==0.3.5+0.g2a2143f.dirty)
Requirement already satisfied: dill in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from pyglyph==0.3.5+0.g2a2143f.dirty)
Requirement already satisfied: numpy in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from pyglyph==0.3.5+0.g2a2143f.dirty)
Requirement already satisfied: pyyaml in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from pyglyph==0.3.5+0.g2a2143f.dirty)
Requirement already satisfied: scipy in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from pyglyph==0.3.5+0.g2a2143f.dirty)
Requirement already satisfied: sympy in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from pyglyph==0.3.5+0.g2a2143f.dirty)
Requirement already satisfied: toolz in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from pyglyph==0.3.5+0.g2a2143f.dirty)
Requirement already satisfied: pyzmq in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from pyglyph==0.3.5+0.g2a2143f.dirty)
Requirement already satisfied: cache.py==0.1.3 in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from pyglyph==0.3.5+0.g2a2143f.dirty)
Requirement already satisfied: mpmath>=0.19 in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from sympy->pyglyph==0.3.5+0.g2a2143f.dirty)
Requirement already satisfied: sqlitedict in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from cache.py==0.1.3->pyglyph==0.3.5+0.g2a2143f.dirty)
Requirement already satisfied: joblib in /Users/bartolkaruza/.pyenv/versions/3.6.4/lib/python3.6/site-packages (from cache.py==0.1.3->pyglyph==0.3.5+0.g2a2143f.dirty)
Installing collected packages: pyglyph
Found existing installation: pyglyph 0.3.5+0.g2a2143f.dirty
Uninstalling pyglyph-0.3.5+0.g2a2143f.dirty:
Successfully uninstalled pyglyph-0.3.5+0.g2a2143f.dirty
Running setup.py develop for pyglyph
Successfully installed pyglyph
readthedocs does not support python 3.5 yet, hence autodoc fails.
Hi
I am learning to use this program, however, when running the lorenz.py example I get this error:
Traceback
File "C:\Users\81599\Documents\Python Scripts\Evolutionary Algorithms\Genetic Programming\Glyph\glyph-master\examples\control\control_problem.py", line 58, in odeint
raise StopIteration
StopIteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\81599\Documents\Python Scripts\Evolutionary Algorithms\Genetic Programming\Glyph\glyph-master\examples\control\lorenz.py", line 137, in
main()
File "C:\Users\81599\Documents\Python Scripts\Evolutionary Algorithms\Genetic Programming\Glyph\glyph-master\examples\control\lorenz.py", line 77, in main
app.run()
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\glyph\application.py", line 184, in run
self.gp_runner.init(self.args.pop_size)
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\glyph\application.py", line 79, in init
self._update()
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\glyph\application.py", line 89, in _update
self._evals = self.assessment_runner(self.population)
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\glyph\assessment.py", line 56, in call
for ind, fit in zip(invalid, fitnesses):
File "C:\Users\81599\Documents\Python Scripts\Evolutionary Algorithms\Genetic Programming\Glyph\glyph-master\examples\control\lorenz.py", line 46, in measure
popt, rmse_opt = assessment.const_opt_leastsq(self.rmse, individual)
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\deprecated\classic.py", line 241, in wrapper_function
return wrapped_(*args_, **kwargs_)
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\glyph\assessment.py", line 177, in const_opt_leastsq
return const_opt(measure, individual, lsq=True, default_constants=default_constants, f_kwargs=f_kwargs, **kwargs)
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\glyph\assessment.py", line 158, in const_opt
res = opt(fun=closure, x0=p0, **kwargs)
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\scipy\optimize_lsq\least_squares.py", line 881, in least_squares
J0 = jac_wrapped(x0, f0)
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\scipy\optimize_lsq\least_squares.py", line 875, in jac_wrapped
kwargs=kwargs, sparsity=jac_sparsity)
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\scipy\optimize_numdiff.py", line 384, in approx_derivative
use_one_sided, method)
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\scipy\optimize_numdiff.py", line 454, in _dense_difference
df = fun(x) - f0
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\scipy\optimize_numdiff.py", line 348, in fun_wrapped
f = np.atleast_1d(fun(x, *args, **kwargs))
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\glyph\assessment.py", line 148, in closure
return measure(individual, *consts, **f_kwargs)
File "C:\Users\81599\Documents\Python Scripts\Evolutionary Algorithms\Genetic Programming\Glyph\glyph-master\examples\control\lorenz.py", line 54, in rmse
y = self.trajectory(individual, *f_args)
File "C:\Users\81599\Documents\Python Scripts\Evolutionary Algorithms\Genetic Programming\Glyph\glyph-master\examples\control\lorenz.py", line 62, in trajectory
return control_problem.integrate(dy, yinit=self.yinit, x=self.x, f_args=f_args)
File "C:\Users\81599\Documents\Python Scripts\Evolutionary Algorithms\Genetic Programming\Glyph\glyph-master\examples\control\control_problem.py", line 25, in integrate
y = np.vstack(res).T
File "<array_function internals>", line 6, in vstack
File "C:\ProgramData\Anaconda3\envs\glyph\lib\site-packages\numpy\core\shape_base.py", line 280, in vstack
arrs = atleast_2d(*tup)
RuntimeError: generator raised StopIteration
thanks in advance
Instead of silently returning the input.
See constraints.py.
Hi,
I was wondering, does glyph support multioutput for symbolic regression? I can not seem to find an example for it.
Thanks
Looks like AExpressionTree
was moved from glyph.gp
to glyph.gp.individual
so some examples cannot start up and fail due to an import error.
Would it makes sense to at least import the examples files in the test suite to ensure they are up to date?
On a fresh conda virtual environment, with glyph installed using pip install pyglyph
, cloning the repos and running make init
as per documentation instructions fail
conda create -n glyph
and conda activate glyph
conda install pip
, pip install pyglyph
git clone https://github.com/Ambrosys/glyph
cd glyph
make init
Installation script fails with error message:
Obtaining file:///Users/simenkva/Code/glyph_testing/glyph
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... error
error: subprocess-exited-with-error
× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> [34 lines of output]
/Users/simenkva/Code/glyph_testing/glyph/versioneer.py:423: SyntaxWarning: invalid escape sequence '\s'
LONG_VERSION_PY['git'] = '''
Traceback (most recent call last):
File "/Users/simenkva/anaconda3/envs/glyph/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/Users/simenkva/anaconda3/envs/glyph/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/simenkva/anaconda3/envs/glyph/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/qc/b2y8zg713_x554g8ykkcbcbh0000gp/T/pip-build-env-dy00n4jd/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 448, in get_requires_for_build_editable
return self.get_requires_for_build_wheel(config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/qc/b2y8zg713_x554g8ykkcbcbh0000gp/T/pip-build-env-dy00n4jd/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/qc/b2y8zg713_x554g8ykkcbcbh0000gp/T/pip-build-env-dy00n4jd/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "/private/var/folders/qc/b2y8zg713_x554g8ykkcbcbh0000gp/T/pip-build-env-dy00n4jd/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 487, in run_setup
super().run_setup(setup_script=setup_script)
File "/private/var/folders/qc/b2y8zg713_x554g8ykkcbcbh0000gp/T/pip-build-env-dy00n4jd/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 311, in run_setup
exec(code, locals())
File "<string>", line 29, in <module>
File "/Users/simenkva/Code/glyph_testing/glyph/versioneer.py", line 1483, in get_version
return get_versions()["version"]
^^^^^^^^^^^^^^
File "/Users/simenkva/Code/glyph_testing/glyph/versioneer.py", line 1415, in get_versions
cfg = get_config_from_root(root)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/simenkva/Code/glyph_testing/glyph/versioneer.py", line 344, in get_config_from_root
parser = configparser.SafeConfigParser()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'configparser' has no attribute 'SafeConfigParser'. Did you mean: 'RawConfigParser'?
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
make: *** [init] Error 1
It seems the installation script uses a deprecated function from configparser
.
Progress bar of the gooey should be updated after each generation.
Hi, as I'm about to use pyglyph for a science projet in school, I am currently going through your code and I think I found something wrong with the SlowConversionTerminator class. Sorry in advance if I'm not using github correctly, I'm new to it, but the concerned code si pretty short, so I hope to be clear enough.
If my understanding is correct, the whole desired effect of using this class is to optimize some function (find the values of its variables so that the result is close to 0), and killing the optimisation process if it detects that the optimisation is too slow, hence the name of the class.
As I first read through this code, I did not understand why the variable "fev" was constantly increasing, then I tested with the following code for myself :
The function used obviously cannot be optimized, I wanted to see if it detects it, but it did not. The process on the whole, just spams the current optimisation method (hill_climb here) until maxfev is reached : the maximum number of iteration (by default maxfev=1000 in this case).
The current if statement never could have been met (in the main loop of the class) :
As fev is constantly increasing, self.memory[fev] is always of length 1 (and self.min_stat is by default 10), and the "break early of the while loop" following this condition is never executed.
I replaced the class code with the following, and it seems to work at least for the case I was testing for.
f(x, c0, c1) = c0*x
f(x, c0, c1) = c0*x
is equivalent to f(x, c0, c1) = c1*x
with swaped c0
and c1
Hello,
I would like to thank you for this amazing project! However, I want to ask if you have thought about a higher-level API, such as classifiers and regressors similar to scikit-learn
with fit
and predict
?
I found this idea in the gplearn
project, which also does symbolic regression.
While your API looks very flexible, it also looks like it is quite verbose for a new and "light" user like me.
Would you be open to a pull request from me, which would let people just create a regressor with given settings (such as population, generations, allowed primitives), and call fit
and predict
on it, similar to gplearn
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.