Skip to content

Commit

Permalink
Merge pull request #1165 from microsoft/dkn_fix
Browse files Browse the repository at this point in the history
DKN quick start notebook and deep dive
  • Loading branch information
miguelgfierro authored Jul 31, 2020
2 parents 9b4ea79 + b5a81d2 commit e452fef
Show file tree
Hide file tree
Showing 12 changed files with 1,260 additions and 312 deletions.
407 changes: 121 additions & 286 deletions examples/00_quick_start/dkn_MIND.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/02_model_content_based_filtering/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ In this directory, notebooks are provided to give a deep dive of content-based f

| Notebook | Environment | Description |
| --- | --- | --- |
| [dkn_deep_dive](dkn_deep_dive.ipynb) | Python GPU | Deep dive into DKN algorithm for news recommendation. |
| [mmlspark_lightgbm_criteo](mmlspark_lightgbm_criteo.ipynb) | PySpark | LightGBM gradient boosting tree algorithm implementation in MML Spark with Criteo dataset.
| [vowpal_wabbit_deep_dive](vowpal_wabbit_deep_dive.ipynb) | Python CPU | Deep dive into using Vowpal Wabbit for regression and matrix factorization.

Expand Down
641 changes: 641 additions & 0 deletions examples/02_model_content_based_filtering/dkn_deep_dive.ipynb

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion reco_utils/dataset/download_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import requests
import math
import zipfile
from contextlib import contextmanager
from tempfile import TemporaryDirectory
from tqdm import tqdm
Expand Down Expand Up @@ -44,7 +45,7 @@ def maybe_download(url, filename=None, work_directory=".", expected_bytes=None):
):
file.write(data)
else:
log.debug("File {} already downloaded".format(filepath))
log.info("File {} already downloaded".format(filepath))
if expected_bytes is not None:
statinfo = os.stat(filepath)
if statinfo.st_size != expected_bytes:
Expand Down Expand Up @@ -79,3 +80,18 @@ def download_path(path=None):
else:
path = os.path.realpath(path)
yield path


def unzip_file(zip_src, dst_dir, clean_zip_file=True):
"""Unzip a file
Args:
zip_src (str): Zip file.
dst_dir (str): Destination folder.
clean_zip_file (bool): Whether or not to clean the zip file.
"""
fz = zipfile.ZipFile(zip_src, "r")
for file in fz.namelist():
fz.extract(file, dst_dir)
if clean_zip_file:
os.remove(zip_src)
Loading

0 comments on commit e452fef

Please sign in to comment.