Fix NameError in MondrianCategorizer.apply() when oob=False - #51
Open
shivamlalakiya wants to merge 1 commit into
Open
Fix NameError in MondrianCategorizer.apply() when oob=False#51shivamlalakiya wants to merge 1 commit into
shivamlalakiya wants to merge 1 commit into
Conversation
apply() calls learner.predict(X) but learner is not a parameter or attribute of apply(); it is self.learner, set in fit(). The oob=False branch (fit's own default and documented combination) therefore raises NameError: name 'learner' is not defined on every call. The sibling line seven lines above already reads self.learner.estimators_.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MondrianCategorizer.apply()'soob=Falsebranch reads a bare namelearner,which is neither a parameter of
apply()nor an attribute on the instance —it is
self.learner, assigned infit(). The branch therefore raisesNameErroron every call:oob=Falseisfit()'s documented default (its own docstring documents thelearnerparameter), so this is the documented, default combination, not anedge case. The
oob=Truebranch two lines above already readsself.learner.estimators_, so this is the one call site that never picked upself..One-line fix:
learner.predict(X)→self.learner.predict(X). The branchcurrently raises unconditionally, so no existing output can change.