gplearn
gplearn copied to clipboard
Custom Feature with specified input type
Hi I'd like to create a custom function that only takes 1 array and 1 constant specifically. For example, a function that changes it to +1 / -1 depending on the constant threshold:
def binary_thresh_(x_array, thresh):
solution = np.zero(x.shape)
solution [x_array<thresh] = -1
solution [x_array>=thresh] = 1
return(solution)
binary_thresh= make_function(function=binary_thresh_, name='binary_thresh', arity=2)
Just would like to check if this is already possible. Thanks.
I assume here that you want to fix thresh
to be a constant and x_array
to be a column from your input data? Presently this is not possible as the inputs to any function can be any of variable, constant or another function.
@trevorstephens Is there any possible to constrain the thresh
not to be a constant?
As above, you cannot presently constrain input types, be that for inclusion or exclusion.
@trevorstephens I custom some functions that require the last input is an integer. Every time I got a new list of program, I pruning it to a standard type. Before call the custom function, I add the integer I need to the program list. Everything seems perfect if I run the whole codes in single one core of CPU. When I tried to run it in more cores. things go well in the first generation, however, from second generation, the custom function just cannot get the last input. Do you have any ideas or suggestions about it?
I custom some functions that require the last input is an integer.
Not sure how you would do that in the current implementation @otthqs ... Anyhow, without some code I cannot help. Open a new issue and include a short, self contained example so that I can understand what you are referring to.
Thanks for your response @trevorstephens . I have already fix it.
Again, thanks for your contribution of gplearn package!