Skip to content

FEAT - Add fit_intercept support to LBFGS solver #325

@floriankozikowski

Description

@floriankozikowski

Description of the feature

The LBFGS solver currently doesn't support fit_intercept=True. A use case of this was described in Issue #320

Considered alternatives

Manual data centering works but complicates the optimization and user experience. In many use cases sklearn is currently is stil the faster alternative.

Additional context

np.random.seed(42)
X = np.random.randn(1000, 50)
y = np.random.poisson(np.exp(X.sum(axis=1) * 0.01 - 1))

# This should work but currently fails as its not supported
estimator = GeneralizedLinearEstimator(
    datafit=Poisson(),
    penalty=L2(alpha=0.01),
    solver=LBFGS(fit_intercept=True)  # <- Currently not supported
)
estimator.fit(X, y)

# Compare with sklearn (works fine)
sklearn_model = PoissonRegressor(alpha=0.01, fit_intercept=True, solver='lbfgs')
sklearn_model.fit(X, y)

Note: Pattern exists in anderson_cd.py (lines 163-166) and other solvers to see how to implement fit_intercept 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