-
Notifications
You must be signed in to change notification settings - Fork 96
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
[Feature]: Count how many variables are in a ComposableExpression
#406
Comments
A lot of the ex::ComposableExpression
tree = ex.tree
target_feature = 1
has_variable = any(node -> node.degree == 0 && node.feature == target_feature, tree) |
See https://ai.damtp.cam.ac.uk/dynamicexpressions/dev/examples/base_operations/ for more examples |
I'm assuming this is fixed; feel free to re-open if not! |
maybe it should have been:
? |
Ah, sorry, I need(ed) coffee! It needs to first check has_variable = any(node -> node.degree == 0 && !node.constant && node.feature == target_feature, tree) A specific method for checking feature equality would no doubt be a good idea. I suppose you can also use |
ahh, I see how that works now, yeah that works. If there's any place where something like this would be useful I'm happy to add a few utility functions, but I'm not sure what to call it. (something like |
Feature Request
Sometimes when looking at the result in HoF, I'm interested in selecting the first equation that used "variable" in both component:
In this case, I'd like to select the equation with
complexity = 10
.I thought I just need to check
![Image](https://private-user-images.githubusercontent.com/5306213/410587710-9046d701-f00b-49f4-ab43-6af381c02560.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNjg3NTcsIm5iZiI6MTczOTM2ODQ1NywicGF0aCI6Ii81MzA2MjEzLzQxMDU4NzcxMC05MDQ2ZDcwMS1mMDBiLTQ5ZjQtYWI0My02YWYzODFjMDI1NjAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMTM1NDE3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NjE1NzFhYTM2MGEwYzk0ODQyZDE5MWUzZjYyYzMxMjM4ZTllYWI4YjNkMDQ0OGExMzg5NGU2MGRhNTg5MzFiNCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.plP5ygz5D-h1HZAIMp8QxZX4-9ZsPHGWstjtD83Z7yg)
.constant
, but then I found this counter-example:So I checked the code base:
SymbolicRegression.jl/src/ComposableExpression.jl
Lines 113 to 115 in ddb7efb
but looks like there's no way to count the non-constant terms
The text was updated successfully, but these errors were encountered: