Refactor light features: replace "metrics" with "features"
Co-authored-by: Meng Li <AnnieLM1996@gmail.com>pull/95/head
parent
f46e8c0666
commit
0809001dfa
|
@ -94,7 +94,7 @@ SCREEN:
|
|||
|
||||
LIGHT:
|
||||
DAY_SEGMENTS: *day_segments
|
||||
METRICS: ["count", "maxlux", "minlux", "avglux", "medianlux", "stdlux"]
|
||||
FEATURES: ["count", "maxlux", "minlux", "avglux", "medianlux", "stdlux"]
|
||||
|
||||
ACCELEROMETER:
|
||||
DAY_SEGMENTS: *day_segments
|
||||
|
|
|
@ -703,7 +703,7 @@ See `Light Config Code`_
|
|||
|
||||
.. - Apply readable dateime to Sensor dataset: ``expand("data/raw/{pid}/{sensor}_with_datetime.csv", pid=config["PIDS"], sensor=config["SENSORS"]),``
|
||||
|
||||
- Extract Light Metrics:
|
||||
- Extract Light Features:
|
||||
|
||||
| ``expand("data/processed/{pid}/light_{day_segment}.csv",``
|
||||
| ``pid=config["PIDS"],``
|
||||
|
@ -719,9 +719,9 @@ See `Light Config Code`_
|
|||
|
||||
- **Script:** ``src/data/readable_datetime.R`` - See the readable_datetime.R_ script.
|
||||
|
||||
- **Rule:** ``rules/features.snakefile/light_metrics`` - See the light_metrics_ rule.
|
||||
- **Rule:** ``rules/features.snakefile/light_features`` - See the light_features_ rule.
|
||||
|
||||
- **Script:** ``src/features/light_metrics.py`` - See the light_metrics.py_ script.
|
||||
- **Script:** ``src/features/light_features.py`` - See the light_features.py_ script.
|
||||
|
||||
.. _light-parameters:
|
||||
|
||||
|
@ -731,14 +731,14 @@ See `Light Config Code`_
|
|||
Name Description
|
||||
============ ===================
|
||||
day_segment The particular ``day_segments`` that will be analyzed. The available options are ``daily``, ``morning``, ``afternoon``, ``evening``, ``night``
|
||||
metrics The different measures that can be retrieved from the Light dataset. See :ref:`Available Light Metrics <light-available-metrics>` Table below
|
||||
features The different measures that can be retrieved from the Light dataset. See :ref:`Available Light Metrics <light-available-features>` Table below
|
||||
============ ===================
|
||||
|
||||
.. _light-available-metrics:
|
||||
.. _light-available-features:
|
||||
|
||||
**Available Light Metrics**
|
||||
**Available Light Features**
|
||||
|
||||
The following table shows a list of the available metrics for the Light dataset.
|
||||
The following table shows a list of the available features for the Light dataset.
|
||||
|
||||
=========== ========= =============
|
||||
Name Units Description
|
||||
|
@ -1175,8 +1175,8 @@ stddurationactivebout minutes Std duration active bout: The standard
|
|||
.. _activity_metrics: https://github.com/carissalow/rapids/blob/765bb462636d5029a05f54d4c558487e3786b90b/rules/features.snakefile#L74
|
||||
.. _google_activity_recognition.py: https://github.com/carissalow/rapids/blob/master/src/features/google_activity_recognition.py
|
||||
.. _`Light Config Code`: https://github.com/carissalow/rapids/blob/765bb462636d5029a05f54d4c558487e3786b90b/config.yaml#L94
|
||||
.. _light_metrics: https://github.com/carissalow/rapids/blob/765bb462636d5029a05f54d4c558487e3786b90b/rules/features.snakefile#L113
|
||||
.. _light_metrics.py: https://github.com/carissalow/rapids/blob/master/src/features/light_metrics.py
|
||||
.. _light_features: https://github.com/carissalow/rapids/blob/765bb462636d5029a05f54d4c558487e3786b90b/rules/features.snakefile#L113
|
||||
.. _light_features.py: https://github.com/carissalow/rapids/blob/master/src/features/light_features.py
|
||||
.. _`Location (Barnett’s) Config Code`: https://github.com/carissalow/rapids/blob/765bb462636d5029a05f54d4c558487e3786b90b/config.yaml#L70
|
||||
.. _phone_sensed_bins: https://github.com/carissalow/rapids/blob/765bb462636d5029a05f54d4c558487e3786b90b/rules/preprocessing.snakefile#L46
|
||||
.. _phone_sensed_bins.R: https://github.com/carissalow/rapids/blob/master/src/data/phone_sensed_bins.R
|
||||
|
|
|
@ -111,16 +111,16 @@ rule screen_features:
|
|||
script:
|
||||
"../src/features/screen_features.py"
|
||||
|
||||
rule light_metrics:
|
||||
rule light_features:
|
||||
input:
|
||||
"data/raw/{pid}/light_with_datetime.csv",
|
||||
params:
|
||||
day_segment = "{day_segment}",
|
||||
metrics = config["LIGHT"]["METRICS"],
|
||||
features = config["LIGHT"]["FEATURES"],
|
||||
output:
|
||||
"data/processed/{pid}/light_{day_segment}.csv"
|
||||
script:
|
||||
"../src/features/light_metrics.py"
|
||||
"../src/features/light_features.py"
|
||||
|
||||
rule accelerometer_features:
|
||||
input:
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import pandas as pd
|
||||
from light.light_base import base_light_features
|
||||
|
||||
light_data = pd.read_csv(snakemake.input[0], parse_dates=["local_date_time", "local_date"])
|
||||
day_segment = snakemake.params["day_segment"]
|
||||
requested_features = snakemake.params["features"]
|
||||
light_features = pd.DataFrame(columns=["local_date"])
|
||||
|
||||
light_features = light_features.merge(base_light_features(light_data, day_segment, requested_features), on="local_date", how="outer")
|
||||
|
||||
assert len(requested_features) + 1 == light_features.shape[1], "The number of features in the output dataframe (=" + str(light_features.shape[1]) + ") does not match the expected value (=" + str(len(requested_features)) + " + 1). Verify your light feature extraction functions"
|
||||
|
||||
light_features.to_csv(snakemake.output[0], index=False)
|
|
@ -1,13 +0,0 @@
|
|||
import pandas as pd
|
||||
from light.light_base import base_light_features
|
||||
|
||||
light_data = pd.read_csv(snakemake.input[0], parse_dates=["local_date_time", "local_date"])
|
||||
day_segment = snakemake.params["day_segment"]
|
||||
metrics = snakemake.params["metrics"]
|
||||
light_features = pd.DataFrame(columns=["local_date"])
|
||||
|
||||
light_features = light_features.merge(base_light_features(light_data, day_segment, metrics), on="local_date", how="outer")
|
||||
|
||||
assert len(metrics) + 1 == light_features.shape[1], "The number of features in the output dataframe (=" + str(light_features.shape[1]) + ") does not match the expected value (=" + str(len(metrics)) + " + 1). Verify your light feature extraction functions"
|
||||
|
||||
light_features.to_csv(snakemake.output[0], index=False)
|
Loading…
Reference in New Issue