Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #175 from wellcometrust/feature/bert_vectorizer_pr…
Browse files Browse the repository at this point in the history
…ogress_bar

new: Add progress bar to transform method
  • Loading branch information
nsorros authored Nov 18, 2020
2 parents 16754b0 + afaaa5b commit adeecc5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
'hdbscan',
'cython',
'flake8',
'black'
'black',
'tqdm'
],
extras_require={
'deep-learning': [
Expand Down
3 changes: 2 additions & 1 deletion wellcomeml/ml/bert_vectorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from sklearn.base import BaseEstimator, TransformerMixin
import numpy as np
import torch
import tqdm

from wellcomeml.utils import check_cache_and_download
from wellcomeml.logger import logger
Expand Down Expand Up @@ -71,7 +72,7 @@ def bert_embedding(self, x):
return embedded_x.cpu().numpy().flatten()

def transform(self, X, *_):
return np.array([self.bert_embedding(x) for x in X])
return np.array([self.bert_embedding(x) for x in tqdm.tqdm(X)])

def fit(self, *_):
model_name = (
Expand Down

0 comments on commit adeecc5

Please sign in to comment.