In [1]:
from pypge.search import PGE
from pypge import expand
from pypge.benchmarks import explicit

import numpy as np

# visualization libraries
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# plot the visuals in ipython
%matplotlib inline


/Users/tony/anaconda/lib/python2.7/site-packages/IPython/html.py:14: ShimWarning: The `IPython.html` package has been deprecated. You should import from `notebook` instead. `IPython.html.widgets` has moved to `ipywidgets`.
  "`IPython.html.widgets` has moved to `ipywidgets`.", ShimWarning)

In [4]:
prob = explicit.Lipson_03(0.1)
print prob['name'], prob['eqn']
print prob['xpts'].shape

plt.plot(prob['xpts'][0], prob['ypure'], 'r.')
plt.show()
plt.plot(prob['xpts'][0], prob['ypts'], 'b.')
plt.show()


Lipson_3 x**2*exp(sin(x)) + x - sin(x**3 - 0.25*pi)
(1, 500)

In [9]:
data = np.array([prob['xpts'][0], prob['ypts']]).T
print data.shape

import json
print json.dumps(data.tolist(), indent=4)


(500, 2)
[
    [
        -2.4854525750436025, 
        0.3414989494981061
    ], 
    [
        12.181005009490818, 
        114.20614137834933
    ], 
    [
        -2.591365656892121, 
        0.8574865980936155
    ], 
    [
        5.954424828588323, 
        31.49149669478132
    ], 
    [
        -2.635193383350103, 
        1.9065726554634201
    ], 
    [
        10.240443979576682, 
        62.02718315264735
    ], 
    [
        0.1547439836956368, 
        0.8084069493255049
    ], 
    [
        -9.15321106553811, 
        55.87891646937048
    ], 
    [
        -13.58888594207407, 
        65.21963403383087
    ], 
    [
        4.83399952105275, 
        14.317846010447147
    ], 
    [
        -11.397805319958849, 
        313.6512105896483
    ], 
    [
        -12.777121977164278, 
        120.38847815883842
    ], 
    [
        1.5696602765385617, 
        8.317160774331787
    ], 
    [
        11.54112622887703, 
        68.33533303131128
    ], 
    [
        12.197662651110065, 
        117.1180424687973
    ], 
    [
        -4.318743729847304, 
        42.38626343405285
    ], 
    [
        -3.532048706785325, 
        15.65542610407293
    ], 
    [
        -8.677328419162558, 
        30.21688849599452
    ], 
    [
        13.456879664249978, 
        408.5042549209802
    ], 
    [
        6.532370170495579, 
        60.12728682551459
    ], 
    [
        7.234013323189622, 
        124.65220625850114
    ], 
    [
        -8.404905382285753, 
        21.07772718440952
    ], 
    [
        -12.166022010700535, 
        205.3174421202774
    ], 
    [
        -11.02988261466928, 
        318.6674161963023
    ], 
    [
        1.1906182414271846, 
        3.9557270973452705
    ], 
    [
        -8.582554082557497, 
        25.35083804614323
    ], 
    [
        -1.9070564116598199, 
        0.5350430567491015
    ], 
    [
        -0.634206671188803, 
        0.3682440582346063
    ], 
    [
        -9.64539261932789, 
        105.73884959118169
    ], 
    [
        -0.6797387285503653, 
        0.6022646869998669
    ], 
    [
        -5.200763295380961, 
        60.18863141104585
    ], 
    [
        -13.423800288016706, 
        71.70086958496063
    ], 
    [
        12.837565666092235, 
        228.73530814424387
    ], 
    [
        -2.8492367320257017, 
        2.2987731169189107
    ], 
    [
        -4.16210767392748, 
        35.68483647429954
    ], 
    [
        5.826583377396986, 
        26.916459919270498
    ], 
    [
        5.274858242909364, 
        16.260596691126242
    ], 
    [
        -0.04602187770442612, 
        0.5984462492474772
    ], 
    [
        -3.097926400820743, 
        5.300097782442111
    ], 
    [
        10.809647024165841, 
        55.02571364119367
    ], 
    [
        4.628502431594118, 
        13.29853606646821
    ], 
    [
        3.1635981452003676, 
        13.51735421412705
    ], 
    [
        -13.841541220402783, 
        60.62020946893386
    ], 
    [
        -2.4185683737781094, 
        1.1958207500078986
    ], 
    [
        -5.795498752395112, 
        48.51072345606178
    ], 
    [
        8.390239362338253, 
        175.45679956740952
    ], 
    [
        1.5761707237400326, 
        8.264022834971774
    ], 
    [
        11.608739979542147, 
        71.84998895171583
    ], 
    [
        12.6615799385274, 
        189.45748715600413
    ], 
    [
        -1.1103171328261183, 
        0.3174159848493844
    ], 
    [
        9.107849837207624, 
        121.42003912550354
    ], 
    [
        -13.982427681975308, 
        59.818741043979024
    ], 
    [
        -10.96861919488523, 
        316.91860089790487
    ], 
    [
        10.333068300710991, 
        58.773119197325464
    ], 
    [
        3.0877440771488516, 
        13.499589823033748
    ], 
    [
        12.916640662790243, 
        248.98012115324232
    ], 
    [
        13.630674807203608, 
        459.3151311628094
    ], 
    [
        -9.324357805663517, 
        70.1590986928151
    ], 
    [
        -12.418241409546205, 
        165.809897928426
    ], 
    [
        8.239398243146454, 
        180.38765670319052
    ], 
    [
        8.596906151841804, 
        162.7705928965295
    ], 
    [
        5.421451777411335, 
        18.132836369351445
    ], 
    [
        -4.209831664671029, 
        38.29895762814093
    ], 
    [
        -5.49939451587781, 
        55.27293775695421
    ], 
    [
        3.98872299974677, 
        11.646120638311306
    ], 
    [
        3.9982308597106666, 
        11.214927462573657
    ], 
    [
        -13.627879636181243, 
        63.5296345517537
    ], 
    [
        5.20731962910903, 
        15.65287741423379
    ], 
    [
        -7.697482411361458, 
        13.505797023032898
    ], 
    [
        2.222116584106182, 
        13.833137306685664
    ], 
    [
        1.411306843637325, 
        5.8011445556758074
    ], 
    [
        10.728795426991702, 
        54.08289278538221
    ], 
    [
        3.0814684475496534, 
        13.423518940145236
    ], 
    [
        11.62432954113481, 
        72.65794317833787
    ], 
    [
        12.229597750641691, 
        119.75538205358849
    ], 
    [
        7.886100021293437, 
        177.29162264101723
    ], 
    [
        6.956189051811521, 
        96.7548832284678
    ], 
    [
        -1.770057388193063, 
        -0.4793005887692318
    ], 
    [
        11.738627582563954, 
        76.8361418208523
    ], 
    [
        0.5391819169177019, 
        1.4585028719248405
    ], 
    [
        1.0466964748210383, 
        3.2612506121103406
    ], 
    [
        -7.502571800607654, 
        15.383856761587245
    ], 
    [
        1.1057144436055992, 
        3.4163922527739583
    ], 
    [
        5.2403230370409375, 
        17.96543565428084
    ], 
    [
        9.191627446452308, 
        115.46968527581762
    ], 
    [
        13.453477235822199, 
        405.78796011477516
    ], 
    [
        6.207804967657729, 
        42.045275063341386
    ], 
    [
        4.526626689946838, 
        12.952257304873013
    ], 
    [
        0.7048787413798543, 
        2.0318594284668996
    ], 
    [
        6.61365057344511, 
        67.63304784035928
    ], 
    [
        7.354171714198991, 
        136.49836885306604
    ], 
    [
        -5.464623982374935, 
        56.88857315467427
    ], 
    [
        -5.967844785867225, 
        42.38788675136322
    ], 
    [
        -7.164318330078141, 
        15.847469771470632
    ], 
    [
        -2.796095572830314, 
        2.4052017163778023
    ], 
    [
        5.444317081329416, 
        19.947005224202805
    ], 
    [
        7.649523957471278, 
        162.89728062462518
    ], 
    [
        -9.906643064469897, 
        145.47948558750437
    ], 
    [
        -3.4347037749267564, 
        11.893296486632893
    ], 
    [
        -6.417187714926612, 
        30.509518920917646
    ], 
    [
        10.718925852174443, 
        55.251083856646055
    ], 
    [
        -13.474929552536485, 
        68.9320302064034
    ], 
    [
        -9.229343670783237, 
        61.88845152965988
    ], 
    [
        3.5715265910825877, 
        11.346477217153987
    ], 
    [
        -3.822464854595278, 
        23.76475722497218
    ], 
    [
        -5.283864557174358, 
        58.87182476778333
    ], 
    [
        -2.3365276914306286, 
        1.209982946161172
    ], 
    [
        11.206077220147066, 
        59.18563660505536
    ], 
    [
        -13.869514791262912, 
        58.522110408798845
    ], 
    [
        10.178573741905684, 
        63.35851619065269
    ], 
    [
        13.475086786220086, 
        412.10604585994435
    ], 
    [
        -13.828292495643556, 
        59.68251082482469
    ], 
    [
        -12.004905119516362, 
        233.64269838883996
    ], 
    [
        8.82288846860309, 
        145.02482400506346
    ], 
    [
        8.148258956065561, 
        181.2874411914347
    ], 
    [
        10.401864460222424, 
        57.52123296932676
    ], 
    [
        -13.304115426635232, 
        76.352230200013
    ], 
    [
        2.940693843348182, 
        13.920107425280495
    ], 
    [
        -10.916761757857481, 
        312.8500793757377
    ], 
    [
        2.2824408667077023e-05, 
        0.7621387115857491
    ], 
    [
        12.209487689356429, 
        117.57920866311531
    ], 
    [
        11.022851127435548, 
        55.45444008731818
    ], 
    [
        6.5788317495121476, 
        63.600773444820696
    ], 
    [
        8.949229887512239, 
        135.94531440924155
    ], 
    [
        -3.2833703247566923, 
        8.315718045799176
    ], 
    [
        -3.5696259194310898, 
        16.42787885921383
    ], 
    [
        13.235038437970829, 
        339.584264927846
    ], 
    [
        -3.594558090047178, 
        16.00129124841448
    ], 
    [
        -2.5964366633575526, 
        0.9113166972660532
    ], 
    [
        -11.328586701304063, 
        318.7065914424886
    ], 
    [
        7.276716516581537, 
        128.8211141385563
    ], 
    [
        3.543624318845435, 
        12.389842021066
    ], 
    [
        1.6042392950704265, 
        8.870262700599929
    ], 
    [
        -12.228943273080978, 
        196.8434100764774
    ], 
    [
        -1.15301594194821, 
        0.08178577680891116
    ], 
    [
        -11.594176197702907, 
        296.3587948477855
    ], 
    [
        7.964637444808705, 
        178.4405405196749
    ], 
    [
        -3.008570370138706, 
        5.1539832961248715
    ], 
    [
        3.913208190595647, 
        10.996231560433447
    ], 
    [
        -13.877040851140425, 
        59.79249022961974
    ], 
    [
        -7.511501790075537, 
        14.002524992288418
    ], 
    [
        -9.513390293357432, 
        90.16889101451338
    ], 
    [
        4.350706156738273, 
        12.01243208587661
    ], 
    [
        -10.53901077892693, 
        262.38116545233345
    ], 
    [
        -0.6472597270376674, 
        0.4377963365507257
    ], 
    [
        7.964800070454562, 
        178.36719949561038
    ], 
    [
        8.554449793101611, 
        165.957685847232
    ], 
    [
        -3.8612717427105334, 
        25.768030823673534
    ], 
    [
        4.0002959872423425, 
        11.156243907771948
    ], 
    [
        -0.19489650402751835, 
        0.5773839503272635
    ], 
    [
        8.046040716260169, 
        181.75637033644455
    ], 
    [
        -10.496616869077782, 
        255.54157463864385
    ], 
    [
        -13.098239166593503, 
        89.21599547353304
    ], 
    [
        2.067129935315286, 
        11.45652054676966
    ], 
    [
        -10.269351163123922, 
        212.39949203401963
    ], 
    [
        -13.977771309350155, 
        57.7906064535942
    ], 
    [
        -12.937674629561613, 
        102.30726016328977
    ], 
    [
        -4.866591852246177, 
        58.801375630563044
    ], 
    [
        11.863291035290327, 
        86.28496099218431
    ], 
    [
        -6.475574761512451, 
        29.144429484747768
    ], 
    [
        -10.68846814702188, 
        285.7532134705893
    ], 
    [
        7.061957541977641, 
        107.97665428565729
    ], 
    [
        11.809592068341303, 
        81.81411245862323
    ], 
    [
        3.6586885672393556, 
        12.68433640576501
    ], 
    [
        1.6608205734227859, 
        9.932903314155427
    ], 
    [
        3.5902188520522245, 
        10.87273806880509
    ], 
    [
        0.8358703826725904, 
        2.4939449282024455
    ], 
    [
        -1.9554570849487298, 
        0.527461620183849
    ], 
    [
        8.305082455887408, 
        177.7116021837365
    ], 
    [
        13.240665866293298, 
        339.6277182651684
    ], 
    [
        -13.786242044227537, 
        61.325353644903345
    ], 
    [
        1.5999630697677976, 
        8.896031156120603
    ], 
    [
        -2.1629577517092358, 
        -1.104700505841207
    ], 
    [
        -1.0650043240082177, 
        0.32935228443239833
    ], 
    [
        4.752352639302444, 
        13.285729263688792
    ], 
    [
        10.189374744485054, 
        61.140306929886705
    ], 
    [
        -5.050195185923217, 
        59.71604060340402
    ], 
    [
        8.867353962985689, 
        143.1585328448999
    ], 
    [
        -13.183100174173958, 
        83.3420504960511
    ], 
    [
        1.6188428388777893, 
        9.19065240620016
    ], 
    [
        0.8654413417023186, 
        2.558418396780246
    ], 
    [
        -0.15216363430350555, 
        0.7359487009306419
    ], 
    [
        7.8512682147467885, 
        176.07421327431967
    ], 
    [
        -8.944944404790936, 
        41.60865859385966
    ], 
    [
        -9.354922351882145, 
        72.70374040229716
    ], 
    [
        2.3120104684493796, 
        14.14788426557655
    ], 
    [
        12.211467739859007, 
        118.69787294158921
    ], 
    [
        -9.537467465074373, 
        93.04957976494248
    ], 
    [
        9.248720331834, 
        112.14714558827859
    ], 
    [
        -7.437517704861249, 
        14.201782829456516
    ], 
    [
        6.683502353498202, 
        72.10763477785869
    ], 
    [
        -10.439579403043165, 
        245.43617147784133
    ], 
    [
        6.711324475726094, 
        75.07027406742485
    ], 
    [
        10.463133372075216, 
        55.64916752615124
    ], 
    [
        4.830238260271752, 
        14.45572535628881
    ], 
    [
        12.835466584957363, 
        227.46901752869692
    ], 
    [
        -8.838082177014279, 
        36.16413617520418
    ], 
    [
        -2.2037730886825475, 
        -0.796793335891322
    ], 
    [
        8.780717094620442, 
        149.9446423590427
    ], 
    [
        4.434911034125786, 
        12.75509504516022
    ], 
    [
        6.360219202592493, 
        50.827888295281575
    ], 
    [
        12.623774444000034, 
        180.96153168632546
    ], 
    [
        -13.589473941161522, 
        64.61278943930937
    ], 
    [
        -3.334674459724246, 
        10.275106329205663
    ], 
    [
        -9.288687714795504, 
        65.21134336275803
    ], 
    [
        9.722754905849119, 
        79.44848158055132
    ], 
    [
        -1.7351534757275537, 
        -0.8183190584679121
    ], 
    [
        -3.2420568787313986, 
        8.234933178561569
    ], 
    [
        2.2177756448836554, 
        13.603065239099562
    ], 
    [
        -7.318926163488614, 
        15.324507461512223
    ], 
    [
        -0.27378749515643364, 
        0.6182986031962825
    ], 
    [
        7.633045262510603, 
        162.86232594182206
    ], 
    [
        0.13284326682294711, 
        0.9268154678264678
    ], 
    [
        6.271811133234021, 
        44.4090865088444
    ], 
    [
        -12.297283519229742, 
        185.42504583536407
    ], 
    [
        6.212396734210042, 
        42.05360906214638
    ], 
    [
        1.2215193955126828, 
        4.22948033877456
    ], 
    [
        -10.192054658446066, 
        197.19081240534044
    ], 
    [
        -4.689377266061399, 
        54.80187956723763
    ], 
    [
        11.948440715214154, 
        91.29075115048519
    ], 
    [
        -1.1566130460049084, 
        -0.10154847086877852
    ], 
    [
        2.799664325268754, 
        13.153846059123925
    ], 
    [
        -11.886887158340997, 
        253.30349220652818
    ], 
    [
        0.7481634352418034, 
        2.4089821731566436
    ], 
    [
        -12.729331254570143, 
        125.73106997524368
    ], 
    [
        9.02898276489158, 
        128.66005368133762
    ], 
    [
        -9.687928223091305, 
        111.33709461679551
    ], 
    [
        -4.776509849256252, 
        57.30205075462909
    ], 
    [
        -3.991181917442029, 
        30.656178127041322
    ], 
    [
        -7.308473560905348, 
        16.330448036507878
    ], 
    [
        -10.597920696075436, 
        271.39499800242174
    ], 
    [
        -7.595793808446319, 
        13.486317844927843
    ], 
    [
        7.541509508175597, 
        153.94584036097953
    ], 
    [
        -11.398420723285529, 
        313.62422062708777
    ], 
    [
        1.6258936010539635, 
        9.09391158088693
    ], 
    [
        -3.0845145991570995, 
        4.927761694146365
    ], 
    [
        -3.58899743082711, 
        16.325668308777505
    ], 
    [
        -0.3017579239322039, 
        0.6413445141201453
    ], 
    [
        13.435062062789363, 
        401.6135548703415
    ], 
    [
        8.258210227373674, 
        179.2022460062476
    ], 
    [
        -6.552153252371605, 
        25.716026410537303
    ], 
    [
        -5.853522481557256, 
        46.55841405497405
    ], 
    [
        -13.075179304170556, 
        91.42154324663345
    ], 
    [
        -8.448319108068393, 
        23.26159059183064
    ], 
    [
        5.25693102474375, 
        17.039731163035153
    ], 
    [
        6.197902453617189, 
        42.27234637054836
    ], 
    [
        -7.1104993543817585, 
        17.873794357593034
    ], 
    [
        -12.863651834578201, 
        109.89805170121524
    ], 
    [
        -10.162506110294416, 
        192.96600910083302
    ], 
    [
        -2.244771121960369, 
        -0.2739300537403547
    ], 
    [
        -4.512139349383732, 
        48.83276483228224
    ], 
    [
        -1.9001756967724255, 
        0.3545696843655609
    ], 
    [
        -13.522856055980848, 
        66.23015359811824
    ], 
    [
        -13.168358731468302, 
        84.9694095402971
    ], 
    [
        -7.6103756665962745, 
        15.318492749303463
    ], 
    [
        13.840691069207104, 
        513.0255861093721
    ], 
    [
        7.791804551602667, 
        171.73206327022623
    ], 
    [
        -5.627788773758567, 
        52.761263277738024
    ], 
    [
        -12.80761444585822, 
        116.41105092558018
    ], 
    [
        -11.715501463176588, 
        279.55880747038594
    ], 
    [
        -4.393979285822738, 
        44.781064632749676
    ], 
    [
        8.341671826358521, 
        175.71211320468797
    ], 
    [
        0.29614419027852, 
        0.9147658126005098
    ], 
    [
        13.243710658625986, 
        342.0084001702296
    ], 
    [
        -7.882366605428383, 
        15.458030382203441
    ], 
    [
        -0.7170034031124715, 
        0.41625321572569135
    ], 
    [
        -8.907026547095512, 
        39.04574503621185
    ], 
    [
        0.014980199971351027, 
        0.6508843325326094
    ], 
    [
        13.797495421120932, 
        502.97942703105355
    ], 
    [
        7.737109317361163, 
        169.8400299057464
    ], 
    [
        5.5024716859486915, 
        19.77106159050416
    ], 
    [
        -1.6535126139274983, 
        -1.362624236671048
    ], 
    [
        11.353169684134834, 
        62.970216748618746
    ], 
    [
        -1.0403214348579422, 
        0.5635028791346401
    ], 
    [
        -3.759165188781717, 
        21.119520753502847
    ], 
    [
        7.734243395725002, 
        169.20119020027167
    ], 
    [
        12.490136228125582, 
        157.24888102044773
    ], 
    [
        6.305776962424574, 
        48.13901828814809
    ], 
    [
        3.403930042903088, 
        11.499754054427461
    ], 
    [
        7.511660453441035, 
        151.362977973177
    ], 
    [
        -8.944168679578304, 
        41.40671837862354
    ], 
    [
        -11.760192113175982, 
        272.7943396270522
    ], 
    [
        10.0332681300088, 
        67.70414195900479
    ], 
    [
        1.9556650848924164, 
        11.366462624606902
    ], 
    [
        11.79335201581178, 
        81.36137610759103
    ], 
    [
        -6.057710578815138, 
        39.86873636128304
    ], 
    [
        -12.851810915535692, 
        111.5959930118138
    ], 
    [
        11.92283788595567, 
        90.57168449571599
    ], 
    [
        -0.4311190521520274, 
        0.3305969523492889
    ], 
    [
        1.894301826343824, 
        11.44393755587241
    ], 
    [
        11.298105988087372, 
        59.72059762540125
    ], 
    [
        0.6111229930403379, 
        1.7063325224334076
    ], 
    [
        4.588402108201741, 
        11.447912435907412
    ], 
    [
        6.858178244284112, 
        86.99241055136368
    ], 
    [
        -12.151712357705126, 
        207.8168351865321
    ], 
    [
        9.137987323415796, 
        119.12416784748507
    ], 
    [
        2.432587309019347, 
        12.940898169060969
    ], 
    [
        8.029617741163406, 
        179.7262843370665
    ], 
    [
        8.352775286499206, 
        176.90329288043634
    ], 
    [
        10.133648425077716, 
        63.50282623420574
    ], 
    [
        -1.761061496697872, 
        -0.41608530936473853
    ], 
    [
        -12.830705703661446, 
        114.98921307342346
    ], 
    [
        4.275981078437521, 
        11.035419376133362
    ], 
    [
        -11.305405477421699, 
        320.59201116168094
    ], 
    [
        -7.173187618031808, 
        15.853070647610766
    ], 
    [
        13.436008307915166, 
        401.5894094396081
    ], 
    [
        -3.075273319373288, 
        4.843488071965881
    ], 
    [
        -6.397434962871281, 
        29.01702802645603
    ], 
    [
        12.028994469966165, 
        99.415669689603
    ], 
    [
        10.369947378543241, 
        57.56720484562584
    ], 
    [
        -13.71299985461901, 
        61.58405698386114
    ], 
    [
        -4.113717498943522, 
        35.589845729628486
    ], 
    [
        -10.531379978993202, 
        260.73202331277537
    ], 
    [
        9.325345892814113, 
        105.79174628270057
    ], 
    [
        1.7785363265611913, 
        11.146364581713064
    ], 
    [
        5.1875304662357635, 
        15.540849658781642
    ], 
    [
        -11.649194618544986, 
        287.70497055044734
    ], 
    [
        8.243014458402804, 
        179.46445933723513
    ], 
    [
        8.731215779774363, 
        154.1234591072481
    ], 
    [
        -11.550372674331507, 
        301.1877709079201
    ], 
    [
        6.681374976514046, 
        71.85210824081119
    ], 
    [
        12.911988220061733, 
        246.78523031931925
    ], 
    [
        9.578109814810361, 
        89.30831386246014
    ], 
    [
        0.5501185473907455, 
        1.6413328281565522
    ], 
    [
        -3.5958025925608847, 
        16.343345138373703
    ], 
    [
        6.250182380147976, 
        45.12061688033602
    ], 
    [
        6.938009658779745, 
        95.2635029082373
    ], 
    [
        13.738992819099568, 
        488.93834874910533
    ], 
    [
        -5.492121821250912, 
        55.789542039427744
    ], 
    [
        4.711320808156479, 
        13.052412300295458
    ], 
    [
        -13.949123734556983, 
        59.38810081361997
    ], 
    [
        -5.127586104378397, 
        59.95724984740024
    ], 
    [
        8.23663160698409, 
        180.6427327498786
    ], 
    [
        -4.069137921307792, 
        32.005060002968385
    ], 
    [
        -8.326966841304708, 
        20.284976380646885
    ], 
    [
        -8.960450427021934, 
        41.45449509492481
    ], 
    [
        13.703085481583901, 
        478.52070650120885
    ], 
    [
        4.232630787505766, 
        11.80773709258651
    ], 
    [
        2.9577334863647877, 
        13.506452597217002
    ], 
    [
        8.405077965825157, 
        173.29801392109573
    ], 
    [
        4.739191843091341, 
        13.714945827569274
    ], 
    [
        -6.462408461642583, 
        29.058873257180657
    ], 
    [
        7.000412922965072, 
        101.37795916328821
    ], 
    [
        2.9600575919638636, 
        13.32017668621091
    ], 
    [
        3.5155438509468517, 
        13.088815124895241
    ], 
    [
        -9.434803698735447, 
        79.170132161542
    ], 
    [
        10.479632668707168, 
        56.16605396595673
    ], 
    [
        -6.497596298589432, 
        26.655893201528283
    ], 
    [
        -10.232267995734015, 
        204.70405019169888
    ], 
    [
        -12.113856264937887, 
        215.5007956320154
    ], 
    [
        -5.284945026972277, 
        58.82643975394706
    ], 
    [
        -10.099929894513561, 
        180.86630958762078
    ], 
    [
        13.18955950885017, 
        324.6977916716576
    ], 
    [
        2.363051822566419, 
        13.69625419783746
    ], 
    [
        6.706941995165799, 
        75.1192008613067
    ], 
    [
        -0.9105447855498561, 
        0.5692927449546258
    ], 
    [
        1.930071014528746, 
        11.41104989938985
    ], 
    [
        -12.940946306129126, 
        103.66003006196617
    ], 
    [
        1.5487301312999513, 
        7.88352336380518
    ], 
    [
        11.50561960064736, 
        66.02119857098532
    ], 
    [
        -8.479779019923363, 
        24.33484732986709
    ], 
    [
        -0.3219555151983098, 
        0.5312333965871517
    ], 
    [
        -4.3365297560156595, 
        43.96501572265748
    ], 
    [
        3.617978899153684, 
        11.344922163229889
    ], 
    [
        -10.630245773977814, 
        277.69786483746833
    ], 
    [
        5.307140800228044, 
        18.37221653476031
    ], 
    [
        -0.8196320069564678, 
        0.6158792651017666
    ], 
    [
        -9.023585357318545, 
        46.484182327872816
    ], 
    [
        10.032156479625549, 
        67.47085257672373
    ], 
    [
        13.151260054056621, 
        314.14286474752026
    ], 
    [
        8.801475222335558, 
        146.98481640963786
    ], 
    [
        11.120295443060076, 
        57.965267372197296
    ], 
    [
        12.308826981612807, 
        130.6688517950149
    ], 
    [
        -8.815563062063966, 
        35.89453474745386
    ], 
    [
        -9.91757228768062, 
        148.74114093232623
    ], 
    [
        -7.541197673828808, 
        14.975428003386341
    ], 
    [
        -11.686048839517357, 
        284.33311530078595
    ], 
    [
        1.6707302971461235, 
        9.886270612233016
    ], 
    [
        13.077024195290203, 
        292.8916909664371
    ], 
    [
        7.99439230794081, 
        178.97553813373855
    ], 
    [
        -11.701557464216961, 
        282.12589784206546
    ], 
    [
        8.954644234119492, 
        134.34492096864153
    ], 
    [
        10.03675012354072, 
        67.61399997942331
    ], 
    [
        -5.825797082997575, 
        46.56959013981176
    ], 
    [
        -4.565544000790112, 
        52.41587667471974
    ], 
    [
        6.956546394437197, 
        97.00745164891782
    ], 
    [
        -3.306837797677673, 
        8.846559774984165
    ], 
    [
        13.811526901110618, 
        504.9141350906936
    ], 
    [
        8.499882167498697, 
        169.84388331169694
    ], 
    [
        9.757109984788801, 
        79.25781809674122
    ], 
    [
        12.688482359590974, 
        194.46489460292977
    ], 
    [
        11.981596574672473, 
        95.45424836267682
    ], 
    [
        9.16983675387974, 
        117.91362088684033
    ], 
    [
        -7.4811429715822815, 
        13.576249350517708
    ], 
    [
        7.32449726377461, 
        134.0746658202446
    ], 
    [
        -13.168764917517516, 
        84.8427998820003
    ], 
    [
        5.013691094156211, 
        15.141592743866068
    ], 
    [
        3.6691776020830282, 
        12.751010790823987
    ], 
    [
        -0.632950746141157, 
        0.574564999732129
    ], 
    [
        3.1460607719389806, 
        14.095028103589293
    ], 
    [
        -4.377618429075564, 
        45.02305523445802
    ], 
    [
        1.5903550978906278, 
        8.547888590791683
    ], 
    [
        -1.3564716189262, 
        -0.6824502527431708
    ], 
    [
        8.409289406619024, 
        173.90442123584816
    ], 
    [
        -0.6367617031316879, 
        0.42136110322341686
    ], 
    [
        -11.09301741823586, 
        322.40460565052445
    ], 
    [
        -9.876055193518033, 
        141.32860386476014
    ], 
    [
        8.772601989877355, 
        149.14099199097183
    ], 
    [
        -5.824301262155732, 
        46.61547724566163
    ], 
    [
        4.8844063419293136, 
        13.321783613973984
    ], 
    [
        -11.647217557555308, 
        288.2660446701379
    ], 
    [
        -8.660825973500895, 
        28.792795596976887
    ], 
    [
        -3.382434503365255, 
        12.071400463819167
    ], 
    [
        -2.952543504878845, 
        5.368858191667476
    ], 
    [
        10.612009761449908, 
        54.660920827476154
    ], 
    [
        7.769670699770177, 
        171.50254281325573
    ], 
    [
        3.101928642229435, 
        13.721748661177974
    ], 
    [
        1.3394662626913494, 
        5.024316847009433
    ], 
    [
        1.6893216358542382, 
        10.148356041975312
    ], 
    [
        8.849549553709714, 
        142.85252606594742
    ], 
    [
        12.494223141275953, 
        156.9321573396702
    ], 
    [
        -9.703029150591433, 
        114.27335465919374
    ], 
    [
        8.883089384174909, 
        140.49770215373948
    ], 
    [
        5.572692366882443, 
        21.296522414995366
    ], 
    [
        3.753433079038963, 
        10.89170270805783
    ], 
    [
        -8.822839321208507, 
        35.71261725632448
    ], 
    [
        4.298529873925396, 
        11.731693891148101
    ], 
    [
        13.231491439623877, 
        337.94455811062994
    ], 
    [
        -9.228377437818505, 
        62.049286299150054
    ], 
    [
        7.699920417879824, 
        167.1480827682169
    ], 
    [
        11.004048384526506, 
        55.90958827328558
    ], 
    [
        4.7565878276443385, 
        12.974284429301779
    ], 
    [
        12.883052119973978, 
        238.54730822302454
    ], 
    [
        13.74553822953225, 
        488.83652211655004
    ], 
    [
        -6.660968093625659, 
        24.860040743338132
    ], 
    [
        -1.2337288363183205, 
        -0.28471074178630473
    ], 
    [
        -3.0642724835461372, 
        4.610644623232938
    ], 
    [
        -9.406711212186778, 
        76.92839298263685
    ], 
    [
        -11.594486496949552, 
        296.39696509693147
    ], 
    [
        -11.146629054825816, 
        322.4613038840025
    ], 
    [
        2.8926557656941725, 
        14.65322456102474
    ], 
    [
        4.425232536908894, 
        12.713835951337957
    ], 
    [
        11.402082096884044, 
        64.23806135029312
    ], 
    [
        -6.268587404641034, 
        34.61779257693751
    ], 
    [
        7.066526824553804, 
        107.92772708938193
    ], 
    [
        -6.960760729538466, 
        18.027591744517952
    ], 
    [
        -12.400585623930896, 
        168.36726031667462
    ], 
    [
        0.7306724274853931, 
        2.1806031245042017
    ], 
    [
        -8.633339572600503, 
        27.777563277099723
    ], 
    [
        8.531741492915586, 
        168.13593341261227
    ], 
    [
        5.975049538458109, 
        33.16403976988141
    ], 
    [
        4.850860302007273, 
        13.327357031858728
    ], 
    [
        -3.134963382119599, 
        6.79564689473241
    ], 
    [
        7.484571961199364, 
        150.7420567317046
    ], 
    [
        -6.993177082931663, 
        18.188931456222477
    ], 
    [
        -12.977370502629181, 
        99.62489378225497
    ], 
    [
        8.490142543985904, 
        168.5056994847703
    ], 
    [
        -13.230308536860363, 
        80.19635887779867
    ], 
    [
        12.616764204117693, 
        179.97589994105886
    ], 
    [
        -7.245377319051254, 
        14.990425923285816
    ], 
    [
        -3.627578971358073, 
        16.39484970638818
    ], 
    [
        -9.97650238316564, 
        158.8739074509837
    ], 
    [
        5.3708354402290475, 
        18.51421560469297
    ], 
    [
        -4.0256213703617085, 
        31.025296601323753
    ], 
    [
        -1.7500544919722358, 
        -0.5069811139836427
    ], 
    [
        -0.8207663223116448, 
        0.4632393475467781
    ], 
    [
        -6.331111495621588, 
        32.03562057761241
    ], 
    [
        -4.640719733675741, 
        53.956106645386555
    ], 
    [
        11.157770601446149, 
        57.8474143763081
    ], 
    [
        -8.045009959283686, 
        16.154673163531033
    ], 
    [
        -13.172989916605943, 
        84.49281624289591
    ], 
    [
        -3.0995374282560793, 
        5.395446983077825
    ], 
    [
        -1.9501311033964814, 
        0.3885069261904126
    ], 
    [
        11.22284864870836, 
        59.44156659100603
    ], 
    [
        0.3645521323885177, 
        1.258665345083982
    ], 
    [
        9.493300114087557, 
        93.21451433493709
    ], 
    [
        9.014272650480802, 
        129.65349445668897
    ], 
    [
        -12.743083517215041, 
        123.87057050627774
    ], 
    [
        5.893694447539534, 
        29.31661442781089
    ], 
    [
        -3.7737332442672518, 
        20.80827950626564
    ], 
    [
        12.621640429278951, 
        181.6060171770073
    ], 
    [
        11.50980543752145, 
        67.13851496447361
    ], 
    [
        11.070207406610471, 
        57.22738097299441
    ], 
    [
        9.431371559965957, 
        97.1632265862242
    ], 
    [
        -9.773137950669991, 
        123.53691787483665
    ], 
    [
        13.606608207955432, 
        453.0122468333036
    ], 
    [
        1.3546156185267826, 
        5.323736755150953
    ], 
    [
        -12.150854744180418, 
        208.29756059413228
    ], 
    [
        -0.01926065760339668, 
        0.6431123470801242
    ], 
    [
        2.86351026664288, 
        14.147551462307066
    ], 
    [
        -7.047528711021721, 
        16.786778998776768
    ], 
    [
        -10.6919551085637, 
        285.4415341809584
    ], 
    [
        12.309688681257427, 
        130.87928406740238
    ], 
    [
        -10.356494814015148, 
        228.56644640727382
    ], 
    [
        -13.160486569178657, 
        85.3829694370782
    ], 
    [
        1.4321556386694603, 
        6.1613506794292885
    ], 
    [
        -12.291129874155034, 
        185.20004983822966
    ], 
    [
        7.671727340857032, 
        166.01681944980263
    ], 
    [
        -13.802403356722593, 
        59.64209253388718
    ], 
    [
        -12.154331352080515, 
        207.6741767845303
    ]
]

In [10]:
pge = PGE(
    system_type = "explicit",
    search_vars = "y",
    usable_vars = prob['xs_str'],
#     usable_funcs = expand.BASIC_BASE[1:],
    pop_count = 3,
    peek_count = 9,
    max_iter = 6
    )

pge.fit(prob['xpts'], prob['ypts'])


train.shape: (1, 500) (500,)
peekn.shape: (1, 16) (16,)



Preloop setup
  create first exprs: 12
  filtering: 12
  memoizing: 12
  unique: 12 / 12
  algebra: 12
  filtering: 3
  memoizing: 3
  unique: 3 / 3
  peek'n: 15
  peek_queue'n: 15
  peek_pop'd 9 of 15
  peek_pop'd 6 of 6
  eval'n: 15
  eval_queue'n: 15
  TOTAL          1.389 seconds


ITER:  0
  eval_pop'd 3 of 15
  expanding'n: 3
  expanded to: 21
  filtering: 21
  memoizing: 20
  unique: 10 / 20
  algebra: 10
  filtering: 1
  memoizing: 1
  unique: 1 / 1
  peek'n: 11
  peek_queue'n: 11
  peek_pop'd 9 of 11
  eval'n: 9
  eval_queue'n: 9
Best so far
      id:  sz           error         r2    expld_vari    theModel
-----------------------------------------------------------------------------------
       0:   3     18421.766648   -0.716177    0.019721  2.074271*x
       6:   5     10515.687410    0.020356    0.020356  1.762897*x + 88.954492
      11:  15      5133.823444    0.521732    0.521732  0.021259*x**3 + 1.195609*x**2 + 5.318377

  TOTAL          1.689 seconds


ITER:  1
  eval_pop'd 3 of 21
  expanding'n: 3
  expanded to: 19
  filtering: 19
  memoizing: 19
  unique: 10 / 19
  algebra: 10
  filtering: 0
  memoizing: 0
  unique: 0 / 0
  peek'n: 10
  peek_queue'n: 10
  peek_pop'd 9 of 12
  eval'n: 9
  eval_queue'n: 9
Best so far
      id:  sz           error         r2    expld_vari    theModel
-----------------------------------------------------------------------------------
       0:   3     18421.766648   -0.716177    0.019721  2.074271*x
       6:   5     10515.687410    0.020356    0.020356  1.762897*x + 88.954492
       1:   6      5709.356989    0.468115    0.468845  1.230533*x**2
      11:  15      5133.823444    0.521732    0.521732  0.021259*x**3 + 1.195609*x**2 + 5.318377
      23:  17      4797.059434    0.553105    0.553105  0.000169*x**5 + 1.204629*x**2 + 5.210923

      15:   5     18724.529144   -0.744382   -0.000026  1.8e-5/x

  TOTAL          1.445 seconds


ITER:  2
  eval_pop'd 3 of 27
  expanding'n: 3
  expanded to: 26
  filtering: 26
  memoizing: 25
  unique: 12 / 25
  algebra: 12
  filtering: 5
  memoizing: 5
  unique: 3 / 5
  peek'n: 15
  peek_queue'n: 15
  peek_pop'd 9 of 18
  eval'n: 9
  eval_queue'n: 9
Best so far
      id:  sz           error         r2    expld_vari    theModel
-----------------------------------------------------------------------------------
       0:   3     18421.766648   -0.716177    0.019721  2.074271*x
       6:   5     10515.687410    0.020356    0.020356  1.762897*x + 88.954492
       1:   6      5709.356989    0.468115    0.468845  1.230533*x**2
      12:   7      5391.574168    0.497719    0.498181  x*(1.231252*x + 2.125112)
      11:  15      5133.823444    0.521732    0.521732  0.021259*x**3 + 1.195609*x**2 + 5.318377
      23:  17      4797.059434    0.553105    0.553105  0.000169*x**5 + 1.204629*x**2 + 5.210923
      33:  19      4413.345522    0.588851    0.588851  1.0e-6*x**7 + 1.214658*x**2 + 4.930244

      15:   5     18724.529144   -0.744382   -0.000026  1.8e-5/x

      34:   6     18724.529206   -0.744383   -0.000025  0

  TOTAL          2.235 seconds


ITER:  3
  eval_pop'd 3 of 33
  expanding'n: 3
  expanded to: 25
  filtering: 25
  memoizing: 23
  unique: 13 / 23
  algebra: 13
  filtering: 4
  memoizing: 4
  unique: 4 / 4
  peek'n: 17
  peek_queue'n: 17
  peek_pop'd 9 of 26
  eval'n: 9
  eval_queue'n: 9
Best so far
      id:  sz           error         r2    expld_vari    theModel
-----------------------------------------------------------------------------------
       0:   3     18421.766648   -0.716177    0.019721  2.074271*x
       6:   5     10515.687410    0.020356    0.020356  1.762897*x + 88.954492
       1:   6      5709.356989    0.468115    0.468845  1.230533*x**2
      12:   7      5391.574168    0.497719    0.498181  x*(1.231252*x + 2.125112)
      11:  15      5133.823444    0.521732    0.521732  0.021259*x**3 + 1.195609*x**2 + 5.318377
      23:  17      4797.059434    0.553105    0.553105  0.000169*x**5 + 1.204629*x**2 + 5.210923
      33:  19      4413.345522    0.588851    0.588851  1.0e-6*x**7 + 1.214658*x**2 + 4.930244

      15:   5     18724.529144   -0.744382   -0.000026  1.8e-5/x
      24:   7     10718.458468    0.001465    0.001465  89.566234 - 0.002026/x
       7:   8      5690.875888    0.469836    0.469836  1.176479*x**2 + 6.602704
      36:  21      5019.548628    0.532377    0.532377  1.0e-6*x**7 + 0.006354*x**4 + 35.818318

      34:   6     18724.529206   -0.744383   -0.000025  0

  TOTAL          2.509 seconds


ITER:  4
  eval_pop'd 3 of 39
  expanding'n: 3
  expanded to: 26
  filtering: 26
  memoizing: 26
  unique: 16 / 26
  algebra: 16
  filtering: 0
  memoizing: 0
  unique: 0 / 0
  peek'n: 16
  peek_queue'n: 16
  peek_pop'd 9 of 33
  eval'n: 9
  eval_queue'n: 9
Best so far
      id:  sz           error         r2    expld_vari    theModel
-----------------------------------------------------------------------------------
       0:   3     18421.766648   -0.716177    0.019721  2.074271*x
       6:   5     10515.687410    0.020356    0.020356  1.762897*x + 88.954492
       1:   6      5709.356989    0.468115    0.468845  1.230533*x**2
      12:   7      5391.574168    0.497719    0.498181  x*(1.231252*x + 2.125112)
      11:  15      5133.823444    0.521732    0.521732  0.021259*x**3 + 1.195609*x**2 + 5.318377
      23:  17      4797.059434    0.553105    0.553105  0.000169*x**5 + 1.204629*x**2 + 5.210923
      33:  19      4413.345522    0.588851    0.588851  1.0e-6*x**7 + 1.214658*x**2 + 4.930244
      58:  27      4390.096759    0.591017    0.591017  1.0e-6*x**7 - 0.00159*x**4 + 1.489497*x**2 - 0.752191

      15:   5     18724.529144   -0.744382   -0.000026  1.8e-5/x
      24:   7     10718.458468    0.001465    0.001465  89.566234 - 0.002026/x
       7:   8      5690.875888    0.469836    0.469836  1.176479*x**2 + 6.602704
      36:  21      5019.548628    0.532377    0.532377  1.0e-6*x**7 + 0.006354*x**4 + 35.818318

      34:   6     18724.529206   -0.744383   -0.000025  0
       2:   7     18329.724614   -0.707602    0.037646  0.017876*x**3
      26:   8      7232.034735    0.326262    0.375302  0.00773*x**4

  TOTAL          2.812 seconds


ITER:  5
  eval_pop'd 3 of 45
  expanding'n: 3
  expanded to: 32
  filtering: 32
  memoizing: 31
  unique: 22 / 31
  algebra: 22
  filtering: 4
  memoizing: 4
  unique: 4 / 4
  peek'n: 26
  peek_queue'n: 26
  peek_pop'd 9 of 50
  eval'n: 9
  eval_queue'n: 9
Best so far
      id:  sz           error         r2    expld_vari    theModel
-----------------------------------------------------------------------------------
       0:   3     18421.766648   -0.716177    0.019721  2.074271*x
       6:   5     10515.687410    0.020356    0.020356  1.762897*x + 88.954492
       1:   6      5709.356989    0.468115    0.468845  1.230533*x**2
      12:   7      5391.574168    0.497719    0.498181  x*(1.231252*x + 2.125112)
      11:  15      5133.823444    0.521732    0.521732  0.021259*x**3 + 1.195609*x**2 + 5.318377
      23:  17      4797.059434    0.553105    0.553105  0.000169*x**5 + 1.204629*x**2 + 5.210923
      33:  19      4413.345522    0.588851    0.588851  1.0e-6*x**7 + 1.214658*x**2 + 4.930244
      58:  27      4390.096759    0.591017    0.591017  1.0e-6*x**7 - 0.00159*x**4 + 1.489497*x**2 - 0.752191
      74:  30      4163.485837    0.612128    0.612128  2.0e-6*x**7 - 0.001734*x**4 + 1.517832*x**2 - 2.780841*x - 0.324866

      15:   5     18724.529144   -0.744382   -0.000026  1.8e-5/x
      24:   7     10718.458468    0.001465    0.001465  89.566234 - 0.002026/x
       7:   8      5690.875888    0.469836    0.469836  1.176479*x**2 + 6.602704
      36:  21      5019.548628    0.532377    0.532377  1.0e-6*x**7 + 0.006354*x**4 + 35.818318

      34:   6     18724.529206   -0.744383   -0.000025  0
       2:   7     18329.724614   -0.707602    0.037646  0.017876*x**3
      26:   8      7232.034735    0.326262    0.375302  0.00773*x**4

      35:   7     18724.529206   -0.744383   -0.000025  0
     TOTAL          5.339 seconds
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-10-e76b5363af8b> in <module>()
      9     )
     10 
---> 11 pge.fit(prob['xpts'], prob['ypts'])

/Users/tony/pypge/pypge/search.pyc in fit(self, X_train, Y_train)
    120                 self.set_data(X_train,Y_train) # *** see note below
    121                 self.preloop()
--> 122                 self.loop(self.max_iter)
    123                 self.finalize()
    124 

/Users/tony/pypge/pypge/search.pyc in loop(self, iterations)
    308                                         T.checkpoint(len(to_eval))
    309 
--> 310                                 self.print_best(24)
    311 
    312 

/Users/tony/pypge/pypge/search.pyc in print_best(self, count)
    322                                         return
    323                                 cnt += 1
--> 324                                 print "  ", m
    325                         print ""
    326 

/Users/tony/pypge/pypge/model.pyc in __str__(self)
     79                         self.pretty_expr()
     80                 fs = "{:5d}:  {:2d}  {:15.6f}  {:10.6f}  {:10.6f}  {:s}"
---> 81                 return fs.format(self.id, self.size(),self.score,self.r2,self.evar,self.pretty)
     82 
     83         def pretty_expr(self, float_format="%.6f"):

/Users/tony/anaconda/lib/python2.7/site-packages/sympy/core/numbers.pyc in __format__(self, format_spec)
    955 
    956     def __format__(self, format_spec):
--> 957         return format(decimal.Decimal(str(self)), format_spec)
    958 
    959 

/Users/tony/anaconda/lib/python2.7/decimal.pyc in __format__(self, specifier, context, _localeconv)
   3659             context = getcontext()
   3660 
-> 3661         spec = _parse_format_specifier(specifier, _localeconv=_localeconv)
   3662 
   3663         # special values don't care about the type or precision

/Users/tony/anaconda/lib/python2.7/decimal.pyc in _parse_format_specifier(format_spec, _localeconv)
   5977     m = _parse_format_specifier_regex.match(format_spec)
   5978     if m is None:
-> 5979         raise ValueError("Invalid format specifier: " + format_spec)
   5980 
   5981     # get the dictionary

ValueError: Invalid format specifier: s

In [11]:
pge.finalize()



Finalizing


Final Results
      id:  sz           error         r2    expld_vari    theModel
-----------------------------------------------------------------------------------
       0:   3     18421.766648   -0.716177    0.019721  2.074271*x
       6:   5     10515.687410    0.020356    0.020356  1.762897*x + 88.954492
       1:   6      5709.356989    0.468115    0.468845  1.230533*x**2
      12:   7      5391.574168    0.497719    0.498181  x*(1.231252*x + 2.125112)
      14:  10      5145.799047    0.520616    0.521088  x**2*(0.021369*x + 1.239193)
      44:  13      5035.185103    0.530921    0.531526  x*(0.04395*x**2 + 1.247248*x - 3.242636)
      23:  17      4797.059434    0.553105    0.553105  0.000169*x**5 + 1.204629*x**2 + 5.210923
      33:  19      4413.345522    0.588851    0.588851  1.0e-6*x**7 + 1.214658*x**2 + 4.930244
      77:  21      4413.345522    0.588851    0.588851  1.0e-6*x**7 + 1.214658*x**2 + 4.930246
      38:  22      4191.094236    0.609556    0.609556  2.0e-6*x**7 + 1.218166*x**2 - 2.752813*x + 5.860771
      74:  30      4163.485837    0.612128    0.612128  2.0e-6*x**7 - 0.001734*x**4 + 1.517832*x**2 - 2.780841*x - 0.324866

      15:   5     18724.529144   -0.744382   -0.000026  1.8e-5/x
      24:   7     10718.458468    0.001465    0.001465  89.566234 - 0.002026/x
       7:   8      5690.875888    0.469836    0.469836  1.176479*x**2 + 6.602704
       3:  10      5391.574168    0.497719    0.498181  1.231252*x**2 + 2.125112*x
       9:  11      5379.867065    0.498810    0.498810  1.18817*x**2 + 2.104916*x + 5.261554
       5:  14      5145.799047    0.520616    0.521088  0.021369*x**3 + 1.239193*x**2
      11:  15      5133.823444    0.521732    0.521732  0.021259*x**3 + 1.195609*x**2 + 5.318377
      48:  17      5035.185103    0.530921    0.531526  0.04395*x**3 + 1.247248*x**2 - 3.242636*x
      18:  18      5019.806573    0.532353    0.532353  0.044191*x**3 + 1.197941*x**2 - 3.295252*x + 6.03251
      29:  20      4625.564510    0.569081    0.569081  0.00028*x**5 + 1.207489*x**2 - 2.821529*x + 6.092464
      58:  27      4390.096759    0.591017    0.591017  1.0e-6*x**7 - 0.00159*x**4 + 1.489497*x**2 - 0.752191
      76:  28      4209.100974    0.607879    0.607879  4.0e-6*x**7 + 0.006441*x**4 - 0.073944*x**3 + 37.03974

      34:   6     18724.529206   -0.744383   -0.000025  0
       2:   7     18329.724614   -0.707602    0.037646  0.017876*x**3
      26:   8      7232.034735    0.326262    0.375302  0.00773*x**4
      21:  10      5690.875888    0.469836    0.469836  1.17648*x**2 + 6.602704
      53:  13      5690.807751    0.469843    0.469843  1.176253*x**2 + 6.6303 - 0.000134/x
      86:  14      5690.807340    0.469843    0.469843  1.176252*x**2 + 6.630388
      22:  16      5630.231067    0.475486    0.475486  -0.002559*x**4 + 1.619517*x**2 - 2.573405
      27:  19      5420.124844    0.495060    0.495060  0.000175*x**5 + 0.006282*x**4 + 35.999024
      36:  21      5019.548628    0.532377    0.532377  1.0e-6*x**7 + 0.006354*x**4 + 35.818318
      57:  24      4816.454223    0.551298    0.551298  2.0e-6*x**7 + 0.006362*x**4 - 2.631277*x + 36.881004
      95:  26      4816.454223    0.551298    0.551298  2.0e-6*x**7 + 0.006362*x**4 - 2.631278*x + 36.881004

      35:   7     18724.529206   -0.744383   -0.000025  0
   
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-11-2d0c095811b0> in <module>()
----> 1 pge.finalize()

/Users/tony/pypge/pypge/search.pyc in finalize(self, nfronts)
    344                 for front in final_list[:nfronts]:
    345                         for m in front:
--> 346                                 print "  ", m
    347                         print ""
    348 

/Users/tony/pypge/pypge/model.pyc in __str__(self)
     79                         self.pretty_expr()
     80                 fs = "{:5d}:  {:2d}  {:15.6f}  {:10.6f}  {:10.6f}  {:s}"
---> 81                 return fs.format(self.id, self.size(),self.score,self.r2,self.evar,self.pretty)
     82 
     83         def pretty_expr(self, float_format="%.6f"):

/Users/tony/anaconda/lib/python2.7/site-packages/sympy/core/numbers.pyc in __format__(self, format_spec)
    955 
    956     def __format__(self, format_spec):
--> 957         return format(decimal.Decimal(str(self)), format_spec)
    958 
    959 

/Users/tony/anaconda/lib/python2.7/decimal.pyc in __format__(self, specifier, context, _localeconv)
   3659             context = getcontext()
   3660 
-> 3661         spec = _parse_format_specifier(specifier, _localeconv=_localeconv)
   3662 
   3663         # special values don't care about the type or precision

/Users/tony/anaconda/lib/python2.7/decimal.pyc in _parse_format_specifier(format_spec, _localeconv)
   5977     m = _parse_format_specifier_regex.match(format_spec)
   5978     if m is None:
-> 5979         raise ValueError("Invalid format specifier: " + format_spec)
   5980 
   5981     # get the dictionary

ValueError: Invalid format specifier: s

In [16]:
final_paretos = pge.get_final_paretos()
print len(final_paretos)
final_list = [item for sublist in final_paretos for item in sublist]
print len(final_list), "\n\n"


10
69 



In [15]:
pge_szs = [m.size() for m in final_list]
pge_scr = [m.score for m in final_list]
pge_evar = [1.0 - m.evar for m in final_list]

pge_szs_f = [m.size() for m in final_paretos[0]]
pge_scr_f = [m.score for m in final_paretos[0]]
pge_evar_f = [1.0 - m.evar for m in final_paretos[0]]

plt.plot(pge_szs, pge_scr, 'b.', pge_szs_f, pge_scr_f, 'ro')
plt.show()
plt.plot(pge_szs, pge_evar, 'b.', pge_szs_f, pge_evar_f, 'ro')
plt.show()



In [34]:
data_p = np.array([pge_szs, pge_evar]).T
data_pf = np.array([pge_evar_f]).T
print data_p.shape, data_pf.shape


pad_len = len(pge_szs) - len(pge_szs_f)
print "pad: ", pad_len
data_pf = np.pad(data_pf, ((0,pad_len),(0,0)), mode='constant', constant_values=0)
print data_pf.shape
all_data = np.concatenate((data_p, data_pf), 1)
print all_data.shape
print json.dumps(all_data.tolist(), indent=4)


(69, 2) (11, 1)
pad:  58
(69, 1)
(69, 3)
[
    [
        3.0, 
        0.9802794803634742, 
        0.9802794803634742
    ], 
    [
        5.0, 
        0.9796444509220995, 
        0.9796444509220995
    ], 
    [
        6.0, 
        0.5311554669139156, 
        0.5311554669139156
    ], 
    [
        7.0, 
        0.5018193804124681, 
        0.5018193804124681
    ], 
    [
        10.0, 
        0.47891175887106274, 
        0.47891175887106274
    ], 
    [
        13.0, 
        0.4684738556083722, 
        0.4684738556083722
    ], 
    [
        17.0, 
        0.4468954307895313, 
        0.4468954307895313
    ], 
    [
        19.0, 
        0.4111485328606257, 
        0.4111485328606257
    ], 
    [
        21.0, 
        0.41114853286062547, 
        0.41114853286062547
    ], 
    [
        22.0, 
        0.39044353945040133, 
        0.39044353945040133
    ], 
    [
        30.0, 
        0.387871533044861, 
        0.387871533044861
    ], 
    [
        5.0, 
        1.0000260101169516, 
        0.0
    ], 
    [
        7.0, 
        0.9985346607890436, 
        0.0
    ], 
    [
        8.0, 
        0.5301636276697407, 
        0.0
    ], 
    [
        10.0, 
        0.5018193838370844, 
        0.0
    ], 
    [
        11.0, 
        0.5011899566328727, 
        0.0
    ], 
    [
        14.0, 
        0.47891175888277293, 
        0.0
    ], 
    [
        15.0, 
        0.47826846241027376, 
        0.0
    ], 
    [
        17.0, 
        0.4684738549939055, 
        0.0
    ], 
    [
        18.0, 
        0.46764661810572683, 
        0.0
    ], 
    [
        20.0, 
        0.43091891453698694, 
        0.0
    ], 
    [
        27.0, 
        0.4089826714292417, 
        0.0
    ], 
    [
        28.0, 
        0.3921210522456493, 
        0.0
    ], 
    [
        6.0, 
        1.0000252783923624, 
        0.0
    ], 
    [
        7.0, 
        0.962354477282755, 
        0.0
    ], 
    [
        8.0, 
        0.6246983673204085, 
        0.0
    ], 
    [
        10.0, 
        0.5301636276697406, 
        0.0
    ], 
    [
        13.0, 
        0.5301572799991721, 
        0.0
    ], 
    [
        14.0, 
        0.5301572416853243, 
        0.0
    ], 
    [
        16.0, 
        0.5245139387774018, 
        0.0
    ], 
    [
        19.0, 
        0.5049403828907087, 
        0.0
    ], 
    [
        21.0, 
        0.46762258787416133, 
        0.0
    ], 
    [
        24.0, 
        0.4487022548967101, 
        0.0
    ], 
    [
        26.0, 
        0.4487022548967101, 
        0.0
    ], 
    [
        7.0, 
        1.0000252783327541, 
        0.0
    ], 
    [
        8.0, 
        0.9985335683594552, 
        0.0
    ], 
    [
        9.0, 
        0.9623493851751905, 
        0.0
    ], 
    [
        10.0, 
        0.59410717651512, 
        0.0
    ], 
    [
        16.0, 
        0.5301572799997577, 
        0.0
    ], 
    [
        18.0, 
        0.5250346631542921, 
        0.0
    ], 
    [
        23.0, 
        0.46762258787416133, 
        0.0
    ], 
    [
        8.0, 
        1.0000252744740554, 
        0.0
    ], 
    [
        9.0, 
        0.9796444509220996, 
        0.0
    ], 
    [
        10.0, 
        0.9781927739631048, 
        0.0
    ], 
    [
        11.0, 
        0.5659699951658353, 
        0.0
    ], 
    [
        17.0, 
        0.5374010538675333, 
        0.0
    ], 
    [
        20.0, 
        0.5257479229263499, 
        0.0
    ], 
    [
        23.0, 
        0.5247490135537757, 
        0.0
    ], 
    [
        24.0, 
        0.46762258787416133, 
        0.0
    ], 
    [
        9.0, 
        0.9985335804813321, 
        0.0
    ], 
    [
        11.0, 
        0.5892256029359428, 
        0.0
    ], 
    [
        16.0, 
        0.565969995254198, 
        0.0
    ], 
    [
        20.0, 
        0.540584342698616, 
        0.0
    ], 
    [
        21.0, 
        0.5301572416853245, 
        0.0
    ], 
    [
        22.0, 
        0.526384011132605, 
        0.0
    ], 
    [
        31.0, 
        0.49705830104219473, 
        0.0
    ], 
    [
        9.0, 
        0.9985346607890436, 
        0.0
    ], 
    [
        10.0, 
        0.9985335804864689, 
        0.0
    ], 
    [
        11.0, 
        0.9623493851752011, 
        0.0
    ], 
    [
        12.0, 
        0.5892256026903442, 
        0.0
    ], 
    [
        22.0, 
        0.5489798769020832, 
        0.0
    ], 
    [
        26.0, 
        0.527267975948567, 
        0.0
    ], 
    [
        9.0, 
        0.9381898984570916, 
        0.0
    ], 
    [
        11.0, 
        0.9781923497664318, 
        0.0
    ], 
    [
        12.0, 
        0.9535341170637399, 
        0.0
    ], 
    [
        14.0, 
        0.9241707103674777, 
        0.0
    ], 
    [
        10.0, 
        0.9586021456727991, 
        0.0
    ], 
    [
        12.0, 
        0.9623493851751916, 
        0.0
    ], 
    [
        11.0, 
        0.9586021493123452, 
        0.0
    ]
]

In [35]:
from pypge.evaluate import Eval

for best_m in final_paretos[0]:
    print best_m
    y_pred = Eval(best_m, pge.vars, prob['xpts'])
    plt.plot(prob['xpts'][0], prob['ypts'], 'r.',prob['xpts'][0], y_pred, 'b.')
    plt.show()


    0:   3     18421.766648   -0.716177    0.019721  2.074271*x
    6:   5     10515.687410    0.020356    0.020356  1.762897*x + 88.954492
    1:   6      5709.356989    0.468115    0.468845  1.230533*x**2
   12:   7      5391.574168    0.497719    0.498181  x*(1.231252*x + 2.125112)
   14:  10      5145.799047    0.520616    0.521088  x**2*(0.021369*x + 1.239193)
   44:  13      5035.185103    0.530921    0.531526  x*(0.04395*x**2 + 1.247248*x - 3.242636)
   23:  17      4797.059434    0.553105    0.553105  0.000169*x**5 + 1.204629*x**2 + 5.210923
   33:  19      4413.345522    0.588851    0.588851  1.0e-6*x**7 + 1.214658*x**2 + 4.930244
   77:  21      4413.345522    0.588851    0.588851  1.0e-6*x**7 + 1.214658*x**2 + 4.930246
   38:  22      4191.094236    0.609556    0.609556  2.0e-6*x**7 + 1.218166*x**2 - 2.752813*x + 5.860771
   74:  30      4163.485837    0.612128    0.612128  2.0e-6*x**7 - 0.001734*x**4 + 1.517832*x**2 - 2.780841*x - 0.324866

In [37]:
from sympy import *

import networkx as nx
G = pge.GRAPH
n_nodes = G.number_of_nodes()
n_edges = G.number_of_edges()
print n_nodes, n_edges

print nx.info(G)

print nx.density(G)

bins = nx.degree_histogram(G)


# pos=nx.graphviz_layout(G,prog="twopi",root=pge.root_model)
# nx.draw_networkx(G,pos,with_labels=False,node_size=30)
# nx.draw_circular(G,with_labels=False,node_size=30)

# pos=nx.shell_layout(G,pge.iter_expands)
# nx.draw_networkx(G,pos,with_labels=False,node_size=30)

plt.yscale('log')
plt.bar(range(0,len(bins)),bins)
plt.draw()


111 173
Name: 
Type: MultiDiGraph
Number of nodes: 111
Number of edges: 173
Average in degree:   1.5586
Average out degree:   1.5586
0.0141687141687