You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using this code for developing an expression in my research, but I have experienced one issue, that I can't change the n_genes to value other than 2.
I havenot modified anything in the code except my data and the parameters of head size and generations.
Please have a look on it, that how can we increase number of genes in this code and what necessary modifications are required in code to make it work.
I have tried using 3 but it throws following error:
TypeError Traceback (most recent call last)
Cell In[325], line 9
6 hof = tools.HallOfFame(3) # only record the best three individuals ever found in all generations
8 # start evolution
----> 9 pop, log = gep.gep_simple(pop, toolbox, n_generations=n_gen, n_elites=1,
10 stats=stats, hall_of_fame=hof, verbose=True)
File c:\programs\python\python39\lib\site-packages\geppy\algorithms\basic.py:100, in gep_simple(population, toolbox, n_generations, n_elites, stats, hall_of_fame, verbose)
98 invalid_individuals = [ind for ind in population if not ind.fitness.valid]
99 fitnesses = toolbox.map(toolbox.evaluate, invalid_individuals)
--> 100 for ind, fit in zip(invalid_individuals, fitnesses):
101 ind.fitness.values = fit
103 # record statistics and log
Cell In[321], line 5, in evaluate_linear_scaling(individual)
2 """Evaluate the fitness of an individual with linearly scaled MSE.
3 Get a and b by minimizing (a*Yp + b - Y)"""
4 func = toolbox.compile(individual)
----> 5 Yp = np.array(list(map(func, bc, fc, ef, tf, bf, lf)))
7 # special cases: (1) individual has only a terminal
8 # (2) individual returns the same value for all test cases, like 'x - x + 10'. np.linalg.lstsq will fail in such cases.
10 if isinstance(Yp, np.ndarray):
File c:\programs\python\python39\lib\site-packages\geppy\tools\parser.py:50, in compile_..(*x)
48 else:
49 return lambda *x: tuple((f(*x) for f in fs))
---> 50 return lambda x: linker((f(*x) for f in fs))
TypeError: add expected 2 arguments, got 3
The text was updated successfully, but these errors were encountered:
I am using this code for developing an expression in my research, but I have experienced one issue, that I can't change the n_genes to value other than 2.
I havenot modified anything in the code except my data and the parameters of head size and generations.
Please have a look on it, that how can we increase number of genes in this code and what necessary modifications are required in code to make it
work.
I have tried using 3 but it throws following error:
TypeError Traceback (most recent call last)
Cell In[325], line 9
6 hof = tools.HallOfFame(3) # only record the best three individuals ever found in all generations
8 # start evolution
----> 9 pop, log = gep.gep_simple(pop, toolbox, n_generations=n_gen, n_elites=1,
10 stats=stats, hall_of_fame=hof, verbose=True)
File c:\programs\python\python39\lib\site-packages\geppy\algorithms\basic.py:100, in gep_simple(population, toolbox, n_generations, n_elites, stats, hall_of_fame, verbose)
98 invalid_individuals = [ind for ind in population if not ind.fitness.valid]
99 fitnesses = toolbox.map(toolbox.evaluate, invalid_individuals)
--> 100 for ind, fit in zip(invalid_individuals, fitnesses):
101 ind.fitness.values = fit
103 # record statistics and log
Cell In[321], line 5, in evaluate_linear_scaling(individual)
2 """Evaluate the fitness of an individual with linearly scaled MSE.
3 Get a and b by minimizing (a*Yp + b - Y)"""
4 func = toolbox.compile(individual)
----> 5 Yp = np.array(list(map(func, bc, fc, ef, tf, bf, lf)))
7 # special cases: (1) individual has only a terminal
8 # (2) individual returns the same value for all test cases, like 'x - x + 10'. np.linalg.lstsq will fail in such cases.
10 if isinstance(Yp, np.ndarray):
File c:\programs\python\python39\lib\site-packages\geppy\tools\parser.py:50, in compile_..(*x)
48 else:
49 return lambda *x: tuple((f(*x) for f in fs))
---> 50 return lambda x: linker((f(*x) for f in fs))
TypeError: add expected 2 arguments, got 3
The text was updated successfully, but these errors were encountered: