Skip to content

Commit

Permalink
Merge pull request #234 from jrzaurin/ffm
Browse files Browse the repository at this point in the history
The `rec` module
  • Loading branch information
jrzaurin authored Sep 24, 2024
2 parents 220eb3f + 8dd61ce commit 9df6585
Show file tree
Hide file tree
Showing 132 changed files with 5,615 additions and 2,427 deletions.
44 changes: 8 additions & 36 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ jobs:
python -m pip install black flake8
- name: Code Style (Black/Flake8)
run: |
# Black code style
black --check --diff pytorch_widedeep tests examples setup.py
# Stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E901,E999,F821,F822,F823 --ignore=E266 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --ignore=E203,E266,E501,E721,E722,F401,F403,F405,F811,W503,C901 --statistics
test:
Expand All @@ -47,41 +44,16 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest-cov codecov faker
python -m pip install pytest pytest-cov codecov faker
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
- name: Test with pytest and generate coverage
run: |
pytest --doctest-modules pytorch_widedeep --cov-report xml --cov-report term --disable-pytest-warnings --cov=pytorch_widedeep tests/
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage${{ matrix.python-version }}
path: .coverage

finish:
needs: test
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install coverage
- name: Download all artifacts
# Downloads coverage1, coverage2, etc.
uses: actions/download-artifact@v4
- name: Convert coverage
run: |
coverage combine coverage*/.coverage*
coverage report --fail-under=90
coverage xml
- name: upload coverage to Codecov
pytest --doctest-modules pytorch_widedeep --cov=pytorch_widedeep --cov-report=xml --cov-report=term --disable-pytest-warnings tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
file: ./coverage.xml
flags: unittests
name: codecov-${{ matrix.python-version }}
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[settings]
profile=black
multi_line_output=3
include_trailing_comma=True
length_sort=1
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The content of this document is organized as follows:
- [Introduction](#introduction)
- [Architectures](#architectures)
- [The ``deeptabular`` component](#the-deeptabular-component)
- [The ``rec`` module](#the-rec-module)
- [Text and Images](#text-and-images)
- [Installation](#installation)
- [Developer Install](#developer-install)
Expand Down Expand Up @@ -795,6 +796,28 @@ encoder-decoder method and constrastive-denoising method. Please, see the
documentation and the examples for details on this functionality, and all
other options in the library.

### The ``rec`` module

This module was introduced as an extension to the existing components in the
library, addressing questions and issues related to recommendation systems.
While still under active development, it currently includes a select number
of powerful recommendation models.

It's worth noting that this library already supported the implementation of
various recommendation algorithms using existing components. For example,
models like Wide and Deep, Two-Tower, or Neural Collaborative Filtering could
be constructed using the library's core functionalities.

The recommendation algorithms in the `rec` module are:

1. [DeepFM: A Factorization-Machine based Neural Network for CTR Prediction](https://arxiv.org/abs/1703.04247)
2. (Deep) Field Aware Factorization Machine (FFM): a Deep Learning version of the algorithm presented in [Field-aware Factorization Machines in a Real-world Online Advertising System](https://arxiv.org/abs/1701.04099)
3. [xDeepFM: Combining Explicit and Implicit Feature Interactions for Recommender Systems](https://arxiv.org/pdf/1803.05170)
4. [Deep Interest Network for Click-Through Rate Prediction](https://arxiv.org/abs/1706.06978)

These can all be used as the `deeptabular` component in the `WideDeep` model.
See the examples for more details.

### Text and Images
For the text component, `deeptext`, the library offers the following models:

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.3
1.6.4
13 changes: 2 additions & 11 deletions examples/scripts/adult_census.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@
import pandas as pd

from pytorch_widedeep import Trainer
from pytorch_widedeep.models import ( # noqa: F401
Wide,
TabMlp,
WideDeep,
TabResnet,
)
from pytorch_widedeep.models import Wide, TabMlp, WideDeep, TabResnet # noqa: F401
from pytorch_widedeep.metrics import Accuracy, Precision
from pytorch_widedeep.datasets import load_adult
from pytorch_widedeep.callbacks import (
LRHistory,
EarlyStopping,
ModelCheckpoint,
)
from pytorch_widedeep.callbacks import LRHistory, EarlyStopping, ModelCheckpoint
from pytorch_widedeep.initializers import XavierNormal, KaimingNormal
from pytorch_widedeep.preprocessing import TabPreprocessor, WidePreprocessor

Expand Down
6 changes: 1 addition & 5 deletions examples/scripts/adult_census_attention_mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
import pandas as pd

from pytorch_widedeep import Trainer
from pytorch_widedeep.models import (
WideDeep,
SelfAttentionMLP,
ContextAttentionMLP,
)
from pytorch_widedeep.models import WideDeep, SelfAttentionMLP, ContextAttentionMLP
from pytorch_widedeep.metrics import Accuracy
from pytorch_widedeep.datasets import load_adult
from pytorch_widedeep.preprocessing import TabPreprocessor
Expand Down
4 changes: 1 addition & 3 deletions examples/scripts/adult_census_cont_den_full_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from pytorch_widedeep.metrics import Accuracy
from pytorch_widedeep.datasets import load_adult
from pytorch_widedeep.preprocessing import TabPreprocessor
from pytorch_widedeep.self_supervised_training import (
ContrastiveDenoisingTrainer,
)
from pytorch_widedeep.self_supervised_training import ContrastiveDenoisingTrainer

use_cuda = torch.cuda.is_available()

Expand Down
4 changes: 1 addition & 3 deletions examples/scripts/adult_census_cont_den_run_all_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
)
from pytorch_widedeep.datasets import load_adult
from pytorch_widedeep.preprocessing import TabPreprocessor
from pytorch_widedeep.self_supervised_training import (
ContrastiveDenoisingTrainer,
)
from pytorch_widedeep.self_supervised_training import ContrastiveDenoisingTrainer

use_cuda = torch.cuda.is_available()

Expand Down
6 changes: 1 addition & 5 deletions examples/scripts/adult_census_enc_dec_run_all_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
from pytorch_widedeep.models import TabMlp as TabMlpEncoder
from pytorch_widedeep.models import TabNet as TabNetEncoder
from pytorch_widedeep.models import TabResnet as TabResnetEncoder
from pytorch_widedeep.models import (
TabMlpDecoder,
TabNetDecoder,
TabResnetDecoder,
)
from pytorch_widedeep.models import TabMlpDecoder, TabNetDecoder, TabResnetDecoder
from pytorch_widedeep.datasets import load_adult
from pytorch_widedeep.preprocessing import TabPreprocessor
from pytorch_widedeep.self_supervised_training import EncoderDecoderTrainer
Expand Down
6 changes: 1 addition & 5 deletions examples/scripts/adult_census_tabnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
from pytorch_widedeep.models import TabNet, WideDeep
from pytorch_widedeep.metrics import Accuracy, Precision
from pytorch_widedeep.datasets import load_adult
from pytorch_widedeep.callbacks import (
LRHistory,
EarlyStopping,
ModelCheckpoint,
)
from pytorch_widedeep.callbacks import LRHistory, EarlyStopping, ModelCheckpoint
from pytorch_widedeep.preprocessing import TabPreprocessor

use_cuda = torch.cuda.is_available()
Expand Down
6 changes: 1 addition & 5 deletions examples/scripts/adult_census_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
)
from pytorch_widedeep.metrics import Accuracy
from pytorch_widedeep.datasets import load_adult
from pytorch_widedeep.callbacks import (
LRHistory,
EarlyStopping,
ModelCheckpoint,
)
from pytorch_widedeep.callbacks import LRHistory, EarlyStopping, ModelCheckpoint
from pytorch_widedeep.initializers import XavierNormal, KaimingNormal
from pytorch_widedeep.preprocessing import TabPreprocessor, WidePreprocessor

Expand Down
Loading

0 comments on commit 9df6585

Please sign in to comment.