Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

FistaRegressor does not converge for real data #151

@arose13

Description

@arose13

I can get the FistaRegressor to converge when data is trivial. The code for the simulated data is below.

from scipy import stats

N, P = 300, 30
m_true = np.zeros(P)
m_true[:4] = [2, -2, 2, 3]

noise = 3 * stats.norm().rvs(N)

data = 3*stats.norm().rvs((N, P))
target = data @ m_true + noise

fista = FistaRegressor(
    C=1/n,
    penalty='l1',
    alpha=lam,   # The same alpha LassoCV.alpha_ finds
    max_iter=1000,
    max_steps=1000,
)
fista.fit(data, target)

image
(X axis are the individual coefficients and the Y axis are the fitted coef magnitude)

But if I use real data I cannot get it to converge at all.

from statsmodels.tools.tools import add_constant
from sklearn.datasets import load_boston

data, target = load_boston(return_X_y=True)
data = add_constant(data)

image
(X axis are the individual coefficients and the Y axis are the fitted coef magnitude)

I assume it has something to do with feature scaling but I'm not sure.

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