Skip to content

Conversation

@jeromedockes
Copy link
Member

@jeromedockes jeromedockes commented Jun 15, 2025

I wonder if it would be useful to allow evaluating an expression step by step, to inspect the results, debug, build reports, test etc. We could add a method .skb.iter_eval() that returns a generator which yields each sub-expression and its result as it evaluates them

>>> import skrub

>>> a = skrub.var('a')
>>> b = skrub.var('b')
>>> c = a * a + b

>>> for item in c.skb.iter_eval({'a': 10, 'b': 20}):
...     print(item)
(<Var 'a'>, 10)
(<BinOp: mul>, 100)
(<Var 'b'>, 20)
(<BinOp: add>, 120)

(note as the pr shows in terms of implementation there is almost nothing to do, as we already use a loop and not recursion to evaluate the expressions)

@jeromedockes jeromedockes added no changelog needed discussion Something somewhat open-ended to discuss data_ops Something related to the skrub DataOps labels Jun 15, 2025
@jeromedockes jeromedockes changed the title Adding .skb.iter_eval? [DISCUSSION] Adding .skb.iter_eval? Jun 15, 2025
@glemaitre
Copy link
Member

When @jeromedockes presented this feature, I thought about some discussions that we had in the past quite related (@GaelVaroquaux): being able to have a sort of probe in the graph for instance to get the feature importance. I'm wondering if this way of iterating would be useful to go in this direction.

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

Labels

data_ops Something related to the skrub DataOps discussion Something somewhat open-ended to discuss no changelog needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants