How to print the solution without stringify?

225 views
Skip to first unread message

Lionel C

unread,
Jun 9, 2014, 9:12:58 AM6/9/14
to deap-...@googlegroups.com
Hi,

I am starting to use the Deap framework in order to complete my MSc project. The topic of my dissertation is to apply Machine Learning techniques to finance and I have chosen to focus on genetic programming.

To get started, I read the documentation and tried to understand some of the examples provided, including symbreg.py. I have been trying to print the solution, but the stringify function was removed from the framework and I could not figure out how to do without it. I tried adding these lines at the end of main():
    tree = gp.PrimitiveTree(hof)
    print(tree)
but I get the following error message:

    AttributeError: 'Individual' object has no attribute 'arity'


I also tried:
    print(hof)
but it would print a list of object references.

Could anyone please guide me?

Lionel
experimenting6.py

Félix-Antoine Fortin

unread,
Jun 9, 2014, 10:12:19 AM6/9/14
to deap
Hi Lionel,

The HallOfFame is a list of individuals (see the documentation). Therefore, to print the first best's representation, you have to access the list using the square brackets, such as :
print(hof[0])

Regards,
Félix-Antoine


--
You received this message because you are subscribed to the Google Groups "deap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deap-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lionel C

unread,
Jun 9, 2014, 10:16:05 AM6/9/14
to deap-...@googlegroups.com
Thank you very much Felix-Antoine.
Reply all
Reply to author
Forward
0 new messages