Skip to main content

A package implementation of COMBSS, a continuous optimisation method toward best subset selection

Project description

COMBSS: Continuous Optimization for Best Subset Selection

PyPI version License

Python implementation of a novel continuous optimization method for best subset selection in linear regression.

📄 Reference:
Moka, Liquet, Zhu & Muller (2024)
COMBSS: best subset selection via continuous optimization
Statistics and Computing

🔗 GitHub Repository: saratmoka/combss

Key Features

  • 🎯 Continuous relaxation of discrete subset selection
  • ⚡ Scalable optimization for high-dimensional data
  • 🔌 Seamless integration with NumPy and SciPy

Intercept Handling

The intercept term (if included) is subject to the same selection process as other features.

Installation

pip install combss

Quick Start

A simple example:

import combss
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split

# Generate sample data
X, y = make_regression(n_samples=1000, n_features=50, noise=0.1, random_state=42)

# Split into training and validation sets (60-40 split)
X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.4, random_state=42)

# Initialize and fit model with validation data
model = combss.linear.model()
model.fit(
    X_train=X_train, 
    y_train=y_train,
    X_val=X_val,      # Validation features
    y_val=y_val,      # Validation targets
    q=10,             # Maximum subset size
    nlam=50           # Number of λ values
)

# Results
print("Best subset indices:", model.subset)
print("Best coefficients:", model.coef_)
print("Validation MSE:", model.mse)
print("Optimal lambda:", model.lambda_)
print("Computation time (s):", model.run_time)

An example with known true coefficients:

import combss
import numpy as np
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split

# Configuration
n_samples = 5000
n_features = 50
n_informative = 5  # the number of non-zero coefficients
noise_level = 0.1

# Generate data with exactly 5 informative features
X, y, true_coef = make_regression(
    n_samples=n_samples,
    n_features=n_features,
    n_informative=n_informative, 
    noise=noise_level,
    coef=True,  # Return the actual coefficients used
    random_state=42
)

# The true coefficients will be non-zero for first 5 features
print("Number of truly informative features:", sum(true_coef != 0))  

# Split data
X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.4, random_state=42)

# Initialize and fit model
model = combss.linear.model()
model.fit(
    X_train=X_train, 
    y_train=y_train,
    X_val=X_val,
    y_val=y_val,
    q=10,
    nlam=50
)

# Results analysis
print("\nTrue non-zero coefficients:", np.where(true_coef != 0)[0])
print("Estimated subset:", model.subset)
print("\nValidation MSE:", model.mse)

Documentation

Core Parameters

Parameter Description Default
q Maximum subset size min(n,p)
nlam Number of λ values 50
scaling Enable feature scaling True
tau Threshold parameter 0.5
delta_frac δ/n in objective function 1

Advanced Options

model.fit(
    ...,
    t_init=t_init,     # Initial point for vector t
    eta=0.001,         # Truncation parameter
    patience=10,       # Early stopping rounds
    gd_maxiter=1000,   # Maximum number of iterations for the gradient based optimization
    cg_tol=1e-6        # Conjugate gradient tolerance
)

Output Attributes

Attribute Description
subset Selected feature indices (0-based)
coef_ Regression coefficients
mse Mean squared error
lambda_ Optimal λ value
run_time Execution time (seconds)
subset_list The list of subsets over the grid
lambda_list The grid of λ values.

Dependencies

  • Python 3.7+
  • NumPy (≥1.21.0)
  • SciPy (≥1.7.0)

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Developers

License

Apache

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

combss-1.1.1.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

combss-1.1.1-py2.py3-none-any.whl (18.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file combss-1.1.1.tar.gz.

File metadata

  • Download URL: combss-1.1.1.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for combss-1.1.1.tar.gz
Algorithm Hash digest
SHA256 699c70afb1d653284e28ceaad6c09c5424eff33cc1fd85008665232464e2b64a
MD5 994e63df22a7cc614bec352fe1a9ff10
BLAKE2b-256 70929c15c4b41daf5ed0a7c8a75b2fb23b1f994e09f66522b970f6aa2f70d55e

See more details on using hashes here.

File details

Details for the file combss-1.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: combss-1.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for combss-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3323ceddc0fd012cd988a39e5b39ab5e09e604910c5c5ed36bba22baca20c639
MD5 4e5758e5ce76e3276f0d9a14ce390302
BLAKE2b-256 c9bf0443d506663d4593942acc872fb04316a5232cff4925c3c7ade02b694451

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page