I get the following error: (note that I use anaconda navigator to create an environment with the required versions of the dependent modules) and the following command line and functions:
operator, arity
+,2
-,2
/,2
*,2
<,2
>=,2
or,2
and,2
(macos-TF2) aymansalsaket@AYMANs-MacBook-Pro latest % python -V
Python 3.8.8
(macos-TF2) aymansalsaket@AYMANs-MacBook-Pro latest % sudo nice -1 python karoo-gp.pypython -V
Select (c)lassification, (r)egression, (m)atching, or (p)lay (default m): c
Select (f)ull, (g)row, or (r)amped 50/50 method (default r): r
Enter depth of the initial population of Trees (default 3): **7**
Enter maximum Tree depth (default 7): **7**
Enter minimum number of nodes for any given Tree (default 3; max 255): **5**
Enter number of Trees in each population (default 100): 75
Enter max number of generations (default 10): 100
In the settings above only 5,5,3 work till the end. Here, I used 7,7,5 and it crashed as shown in the trace:
ERROR TRACE:
Evaluate all Trees in Generation 4
ValueError: Error from parse_expr with transformed code:
"(((Symbol ('A1x' ))>=(Symbol ('A21x' )))<((Symbol ('A11x' ))>=(Symbol ('A2x' ))))"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "karoo-gp.py", line 593, in <module>
gp.fit(X, y)
File "/Users/aymansalsaket/Desktop/latest/karoo_gp/base_class.py", line 804, in fit
super().fit(X, y, *args, **kwargs)
File "/Users/aymansalsaket/Desktop/latest/karoo_gp/base_class.py", line 460, in fit
self.population.evaluate(X_train, y_train, self.X_train_hash)
File "/Users/aymansalsaket/Desktop/latest/karoo_gp/population.py", line 93, in evaluate
predictions = self.model.batch_predict(X, self.trees, X_hash)
File "/Users/aymansalsaket/Desktop/latest/karoo_gp/base_class.py", line 494, in batch_predict
y = self.engine.predict(trees, X, X_hash)
File "/Users/aymansalsaket/Desktop/latest/karoo_gp/engine.py", line 155, in predict
expr = tree.expression
File "/Users/aymansalsaket/Desktop/latest/karoo_gp/tree.py", line 76, in expression
return self.root.parse(simplified=True)
File "/Users/aymansalsaket/Desktop/latest/karoo_gp/node.py", line 203, in parse
return (f'({self.children[0].parse(simplified)}'
File "/Users/aymansalsaket/Desktop/latest/karoo_gp/node.py", line 203, in parse
return (f'({self.children[0].parse(simplified)}'
File "/Users/aymansalsaket/Desktop/latest/karoo_gp/node.py", line 200, in parse
return (f'({self.children[0].parse(simplified)}{ws}{self.label}'
File "/Users/aymansalsaket/Desktop/latest/karoo_gp/node.py", line 200, in parse
return (f'({self.children[0].parse(simplified)}{ws}{self.label}'
File "/Users/aymansalsaket/Desktop/latest/karoo_gp/node.py", line 200, in parse
return (f'({self.children[0].parse(simplified)}{ws}{self.label}'
File "/Users/aymansalsaket/Desktop/latest/karoo_gp/node.py", line 172, in parse
result = str(sympify(raw_expr))
File "/opt/anaconda3/envs/macos-TF2/lib/python3.8/site-packages/sympy/core/sympify.py", line 495, in sympify
expr = parse_expr(a, local_dict=locals, transformations=transformations, evaluate=evaluate)
File "/opt/anaconda3/envs/macos-TF2/lib/python3.8/site-packages/sympy/parsing/sympy_parser.py", line 1105, in parse_expr
raise e from ValueError(f"Error from parse_expr with transformed code: {code!r}")
File "/opt/anaconda3/envs/macos-TF2/lib/python3.8/site-packages/sympy/parsing/sympy_parser.py", line 1096, in parse_expr
rv = eval_expr(code, local_dict, global_dict)
File "/opt/anaconda3/envs/macos-TF2/lib/python3.8/site-packages/sympy/parsing/sympy_parser.py", line 915, in eval_expr
expr = eval(
File "<string>", line 1, in <module>
TypeError: '<' not supported between instances of 'GreaterThan' and 'GreaterThan'
bug