Skip to content

Chaper 6 Backward Selection results in empty set #40

Open
@juejung

Description

@juejung

There appears to be an error with the backward selection algorithm?

While

strategy = Stepwise.first_peak(design,
                               direction='forward',
                               max_terms=len(design.terms))

df_Cp = sklearn_selected(OLS,
                         strategy,
                         scoring=neg_Cp)

df_Cp.fit(Hitters, Y)
print(df_Cp.selected_state_)

works fine and results in

('Assists', 'AtBat', 'CAtBat', 'CRBI', 'CRuns', 'CWalks', 'Division', 'Hits', 'PutOuts', 'Walks')

If I change the algorithm to 'backward' I get an empty set:

strategy = Stepwise.first_peak(design,
                               direction='backward',
                               max_terms=len(design.terms))

df_Cp = sklearn_selected(OLS,
                         strategy,
                         scoring=neg_Cp)

df_Cp.fit(Hitters, Y)
print(df_Cp.selected_state_)

results in empty selections

()
()

Since I get similar outcomes with other data sets, I have a suspicion that the 'backward' method is not implemented correctly?

I also noticed that the wrapper does not warn the user when typing a keyword different from 'forward', 'backward' or 'both' and seems to simply revert to 'forward' as the standard method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions