-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: activity datapoint vectorizer that makes use of field-specific …
…DSPNs
- Loading branch information
Francesco Stablum
committed
Nov 25, 2021
1 parent
a825644
commit 2a6be55
Showing
3 changed files
with
38 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from common import relspecs, utils | ||
from models import models_storage | ||
import numpy as np | ||
|
||
class Activity(utils.Collection): | ||
def __init__(self, activity_data): | ||
for rel in relspecs: | ||
self[rel.name] = rel.extract_from_activity_data(activity_data) | ||
|
||
|
||
class ActivityVectorizer(object): | ||
def __init__(self): | ||
self.model_storage = models_storage.DSPNAEModelsStorage() | ||
|
||
def vectorize_activity(self, activity): | ||
vectorized_fields = [] | ||
for rel in relspecs: | ||
field_data = activity[rel.name] | ||
vectorized_field = self.model_storage[rel.name].encoder(field_data) | ||
vectorized_fields.append(vectorized_field) | ||
ret = np.hstack(vectorized_fields) | ||
return ret |