Skip to content

Commit

Permalink
Make scikitlearn optional (#73)
Browse files Browse the repository at this point in the history
* make scikilearn optional

* fix ci
  • Loading branch information
aloctavodia authored Jan 3, 2025
1 parent e5a0919 commit bc93b02
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: |
conda install pip
pip install -r requirements-dev.txt
pip install .
pip install ".[lasso]"
python --version
conda list
pip freeze
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Assuming a standard Python environment is installed on your machine (including p

pip install kulprit

By default Kulprit performs a forward search, if you want to use Lasso (L1 search) you need to install `scikit-learn` package. You can install it using pip:

pip install kulprit[lasso]

Alternatively, if you want the bleeding edge version of the package you can install it from GitHub:

pip install git+https://github.com/bambinos/kulprit.git
Expand Down
7 changes: 7 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ Assuming a standard Python environment is installed on your machine (including p
pip install kulprit
By default Kulprit performs a forward search, if you want to use Lasso (L1 search) you need to install `scikit-learn` package. You can install it using pip:

.. code-block:: bash
pip install kulprit[lasso]
Alternatively, if you want the bleeding edge version of the package you can install it from GitHub:

.. code-block:: bash
Expand Down
6 changes: 5 additions & 1 deletion kulprit/projection/search_strategies.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"""This module contains the search strategies"""

import numpy as np
from sklearn.linear_model import lasso_path

try:
from sklearn.linear_model import lasso_path
except ImportError:
pass
from kulprit.projection.arviz_io import compute_loo


Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ description = "Kullback-Leibler projections for Bayesian model selection."
dependencies = [
"arviz>=0.17.1",
"bambi>=0.12.0",
"scikit-learn>=1.0.2",
"numba>=0.56.0",]
"numba>=0.56.0",
]

[project.optional-dependencies]
lasso = ["scikit-learn>=1.0.2"]

[tool.flit.module]
name = "kulprit"
Expand Down

0 comments on commit bc93b02

Please sign in to comment.