Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Feature with specified input type #175

Open
jeremytanjianle opened this issue Jun 2, 2019 · 6 comments
Open

Custom Feature with specified input type #175

jeremytanjianle opened this issue Jun 2, 2019 · 6 comments

Comments

@jeremytanjianle
Copy link

jeremytanjianle commented Jun 2, 2019

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.

@trevorstephens
Copy link
Owner

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.

@xiaoxiaoyaozi
Copy link

@trevorstephens Is there any possible to constrain the thresh not to be a constant?

@trevorstephens
Copy link
Owner

As above, you cannot presently constrain input types, be that for inclusion or exclusion.

@otthqs
Copy link

otthqs commented Aug 16, 2019

@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?

@trevorstephens
Copy link
Owner

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.

@otthqs
Copy link

otthqs commented Aug 19, 2019

Thanks for your response @trevorstephens . I have already fix it.

Again, thanks for your contribution of gplearn package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants