Skip to content

Commit

Permalink
MAINT: add optional packages for tensorflow and tensorflow-cpu; updat…
Browse files Browse the repository at this point in the history
…e documentation (#262)
  • Loading branch information
metasyn committed Jan 6, 2022
1 parent 57918d6 commit cbc7940
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 18 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- name: Set up Python
uses: actions/setup-python@v2

- name: Update packages
run: |
pip install -U pip wheel
Expand Down Expand Up @@ -44,9 +44,9 @@ jobs:
- name: Install Dependencies
run: |
poetry install
poetry install -E tensorflow
- name: Test with pytest
- name: Test with pytest
run: |
poetry run python -m pip freeze
poetry run python -m pytest -v --cov=scikeras --cov-report xml --color=yes
Expand Down Expand Up @@ -119,11 +119,10 @@ jobs:
- name: Install Dependencies
run: |
poetry install
poetry add "tensorflow==${{matrix.tf-version}}"
poetry install -E tensorflow
poetry add "scikit-learn==${{matrix.sklearn-version}}"
- name: Test with pytest
- name: Test with pytest
run: |
poetry run python -m pip freeze
poetry run python -m pytest -v --cov=scikeras --cov-report xml --color=yes
Expand Down Expand Up @@ -155,7 +154,7 @@ jobs:
- name: Install Dependencies
run: |
poetry install
poetry install -E tensorflow
- name: Test with pytest
run: |
Expand Down
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,24 @@ An overview of the advantages and differences as compared to the TF wrappers can
This package is available on PyPi:

```bash
pip install scikeras
# Normal tensorflow
pip install scikeras[tensorflow]

# or tensorflow-cpu
pip install scikeras[tensorflow-cpu]
```

The current version of SciKeras depends on `scikit-learn>=1.0.0` and `TensorFlow>=2.7.0`.
SciKeras packages TensorFlow as an optional dependency because there are
several flavors of TensorFlow available (`tensorflow`, `tensorflow-cpu`, etc.).
Depending on _one_ of them in particular disallows the usage of the other, which is why
they need to be optional.

You will need to manually install TensorFlow; due to TensorFlow's packaging it is not a direct dependency of SciKeras.
You can do this by running:
`pip install scikeras[tensorflow]` is basically equivalent to `pip install scikeras tensorflow`
and is offered just for convenience. You can also install just SciKeras with
`pip install scikera`s, but you will need a version of tensorflow installed at
runtime or SciKeras will throw an error when you try to import it.

```bash
pip install tensorflow
```
The current version of SciKeras depends on `scikit-learn>=1.0.0` and `TensorFlow>=2.7.0`.

### Migrating from `tf.keras.wrappers.scikit_learn`

Expand Down
2 changes: 1 addition & 1 deletion docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To install with pip, run:

.. code:: bash
pip install scikeras
pip install scikeras[tensorflow]
We recommend to use a virtual environment for this.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/notebooks/Benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SciKeras wraps Keras Models, but does not alter their performance since all of t
try:
import scikeras
except ImportError:
!python -m pip install scikeras
!python -m pip install scikeras[tensorflow]
```

Silence TensorFlow logging to keep output succinct.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/notebooks/DataTransformers.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ In this notebook, we explore how to reconcile this functionality with the sklear
try:
import scikeras
except ImportError:
!python -m pip install scikeras
!python -m pip install scikeras[tensorflow]
```

Silence TensorFlow warnings to keep output succint.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/notebooks/Meta_Estimators.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ In this notebook, we implement sklearn ensemble and tree meta-estimators backed
try:
import scikeras
except ImportError:
!python -m pip install scikeras
!python -m pip install scikeras[tensorflow]
```

Silence TensorFlow logging to keep output succinct.
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ importlib-metadata = {version = "^3", python = "<3.8"}
python = ">=3.7.0,<3.10.0"
scikit-learn = ">=1.0.0"
packaging = ">=0.21,<22.0"
tensorflow = {version = ">=2.7.0", optional = true}
tensorflow-cpu = {version = ">=2.7.0", optional = true}

[tool.poetry.extras]
tensorflow = ["tensorflow"]
tensorflow-cpu = ["tensorflow-cpu"]

[tool.poetry.dev-dependencies]
tensorflow = ">=2.7.0"
Expand Down

0 comments on commit cbc7940

Please sign in to comment.