Skip to content

FEAT - Support for Poisson Group Lasso #317

Open
@jonpedros

Description

@jonpedros

Hi skglm team,

I'm trying to fit a Poisson Group Lasso model by combining the Poisson datafit, WeightedGroupL2 penalty, and the GroupBCD solver.

This fails with

ValueError: 'Poisson' is not block-separable. Missing 'grp_ptr' attribute., because the standard Poisson datafit isn't compatible with the group solver.

Is there a current workaround for this? If not, please consider this a feature request to add a PoissonGroup datafit, similar to the existing QuadraticGroup and LogisticGroup. This would be a great addition for modeling count data with grouped features.

import numpy as np
from skglm import GeneralizedLinearEstimator
from skglm.datafits import Poisson
from skglm.penalties import WeightedGroupL2
from skglm.solvers import GroupBCD

# Sample data and group structure
n_samples, n_features = 20, 10
X = np.random.randn(n_samples, n_features)
y = np.random.poisson(np.abs(X[:, 0] + X[:, 5]))

grp_ptr = np.array([0, 3, 5, 8, 10], dtype=np.int32)
grp_indices = np.arange(n_features, dtype=np.int32)

# Estimator setup
estimator = GeneralizedLinearEstimator(
    datafit=Poisson(),
    penalty=WeightedGroupL2(alpha=0.1, grp_ptr=grp_ptr, grp_indices=grp_indices,
                            weights=np.ones(len(grp_ptr) - 1)),
    solver=GroupBCD()
)

estimator.fit(X, y)

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