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
{{ message }}
Repository navigation
Pipeline.fit mutates in place while every estimator fit returns a value #356
From community criticism review. Hacker News 18025988, u/zeec123:
If X is your input space and Y your output space then fit should (after each call) return a function X->Y and not modify some internal state.
Have you ever tried looked at the pipeline cross validation, where you have to pass a dict of parameters to the function with underscore prefixes for each stage in the pipeline? Do this and you never call the API design amazing again.
Current state
flow-scikit already answers the first half of that, by accident of the language. Flow structs pass by value, so logistic_regression_fit (linear.flow:443) and every other estimator fit returns a fitted struct rather than mutating a receiver. That is close to what zeec123 asked for.
Pipeline breaks the pattern. pipeline_fit (pipeline.flow:159) is declared -> void and mutates the pipeline in place. So the one place in the library where the stateful-fit criticism lands is the composite estimator, and it is inconsistent with everything it wraps.
Worth deciding
Making pipeline_fit return a fitted Pipeline would make the library uniform: fit is a value-producing operation everywhere. The catch is that Pipeline owns heap allocations for its steps, so a returning version needs its ownership story worked out to avoid double frees against pipeline_free.
The second half of the complaint, the stage__param double-underscore convention for grid search, does not apply: flow-scikit has no string-keyed parameter dict, so there is nothing to fix there. Worth noting explicitly rather than leaving it implied.
Activity