Convert the class into a YAML object.

Add an example config file and demonstrate its usage in ex_ml_pipeline.ipynb.
rapids
junos 2021-08-19 16:31:42 +02:00
parent 52664eb40b
commit 0ed34e97b3
5 changed files with 18 additions and 11 deletions

View File

@ -27,7 +27,7 @@ To install:
ipython kernel install --user --name=straw2analysis
```
2. Provide an .env file to be used by `python-dotenv` which should be placed in the top folder of the application
2. Provide a file called `.env` to be used by `python-dotenv` which should be placed in the top folder of the application
and should have the form:
```

View File

@ -15,6 +15,7 @@ dependencies:
- psycopg2
- python-dotenv
- pytz
- pyyaml
- seaborn
- scikit-learn
- sqlalchemy

View File

@ -18,6 +18,7 @@
import datetime
import os
import sys
import yaml
import seaborn as sns
from sklearn import linear_model
@ -156,20 +157,17 @@ lin_reg_proximity.score(
from machine_learning import pipeline
# %%
ml_pipeline = pipeline.MachineLearningPipeline(
labels_questionnaire="PANAS", data_types="proximity"
)
with open('../machine_learning/config/minimal_features.yaml', 'r') as file:
sensor_features = yaml.full_load(file)
# %%
ml_pipeline.get_labels()
# %% tags=[]
ml_pipeline.get_sensor_data()
sensor_features.set_sensor_data()
# %%
ml_pipeline.aggregate_daily()
sensor_features.get_sensor_data("proximity")
# %%
ml_pipeline.df_full_data_daily_means
sensor_features.calculate_features()
# %%
sensor_features.get_features("proximity", "all")

View File

@ -0,0 +1,5 @@
--- !SensorFeatures
grouping_variable: date_lj
data_types: [proximity]
feature_names: all
participants_usernames: [nokia_0000003]

View File

@ -1,6 +1,7 @@
import datetime
import pandas as pd
import yaml
from sklearn.model_selection import cross_val_score
import participants.query_db
@ -8,7 +9,9 @@ from features import esm, helper, proximity
from machine_learning import QUESTIONNAIRE_IDS, QUESTIONNAIRE_IDS_RENAME
class SensorFeatures:
class SensorFeatures(yaml.YAMLObject):
yaml_tag = u'!SensorFeatures'
def __init__(
self,
grouping_variable,