Accept nested feature configuration.
To do this, pass a dict as parameters to SensorFeatures class, rather than actually reading the object from yaml file.rapids
parent
429aa43bd1
commit
5be3e82797
|
@ -158,7 +158,11 @@ from machine_learning import pipeline
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
with open("../machine_learning/config/minimal_features.yaml", "r") as file:
|
with open("../machine_learning/config/minimal_features.yaml", "r") as file:
|
||||||
sensor_features = yaml.full_load(file)
|
sensor_features_params = yaml.safe_load(file)
|
||||||
|
|
||||||
|
# %%
|
||||||
|
sensor_features = pipeline.SensorFeatures(**sensor_features_params)
|
||||||
|
sensor_features.data_types
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
sensor_features.get_sensor_data("proximity")
|
sensor_features.get_sensor_data("proximity")
|
||||||
|
@ -174,3 +178,5 @@ sensor_features.calculate_features()
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
sensor_features.get_features("proximity", "all")
|
sensor_features.get_features("proximity", "all")
|
||||||
|
|
||||||
|
# %%
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- !SensorFeatures
|
|
||||||
grouping_variable: date_lj
|
grouping_variable: date_lj
|
||||||
data_types: [proximity]
|
features:
|
||||||
feature_names: all
|
proximity:
|
||||||
|
all
|
||||||
participants_usernames: [nokia_0000003]
|
participants_usernames: [nokia_0000003]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
from collections.abc import Collection
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import yaml
|
|
||||||
from sklearn.model_selection import cross_val_score
|
from sklearn.model_selection import cross_val_score
|
||||||
|
|
||||||
import participants.query_db
|
import participants.query_db
|
||||||
|
@ -9,21 +9,16 @@ from features import communication, esm, helper, proximity
|
||||||
from machine_learning import QUESTIONNAIRE_IDS, QUESTIONNAIRE_IDS_RENAME
|
from machine_learning import QUESTIONNAIRE_IDS, QUESTIONNAIRE_IDS_RENAME
|
||||||
|
|
||||||
|
|
||||||
class SensorFeatures(yaml.YAMLObject):
|
class SensorFeatures:
|
||||||
yaml_tag = u"!SensorFeatures"
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
grouping_variable,
|
grouping_variable: str,
|
||||||
data_types,
|
features: dict,
|
||||||
feature_names=None,
|
participants_usernames: Collection = None,
|
||||||
participants_usernames=None,
|
|
||||||
):
|
):
|
||||||
self.data_types = data_types
|
|
||||||
self.grouping_variable = grouping_variable
|
self.grouping_variable = grouping_variable
|
||||||
|
|
||||||
if feature_names is None:
|
self.data_types = features.keys()
|
||||||
self.feature_names = []
|
|
||||||
|
|
||||||
if participants_usernames is None:
|
if participants_usernames is None:
|
||||||
participants_usernames = participants.query_db.get_usernames(
|
participants_usernames = participants.query_db.get_usernames(
|
||||||
|
|
Loading…
Reference in New Issue