Added standardization on SO features.

sociality-task
primoz 2022-06-06 13:51:15 +00:00
parent 2acf6ff9fb
commit 2c7ac21465
2 changed files with 9 additions and 8 deletions

View File

@ -4,4 +4,3 @@ PSQL_STRAW:
password: kizi-x2yf-mate
host: 212.235.208.113
port: 5432

View File

@ -1,5 +1,6 @@
import pandas as pd
from utils.utils import fetch_provider_features, run_provider_cleaning_script
from sklearn.preprocessing import StandardScaler
import sys
@ -9,12 +10,7 @@ provider = snakemake.params["provider"]
provider_key = snakemake.params["provider_key"]
sensor_key = snakemake.params["sensor_key"]
calc_windows = False
try:
calc_windows = provider["WINDOWS"]["COMPUTE"]
except KeyError:
print("WINDOWS COMPUTE key not found in config.yaml!")
calc_windows = True if (provider.get("WINDOWS", False) and provider["WINDOWS"].get("COMPUTE", False)) else False
if sensor_key == "all_cleaning_individual" or sensor_key == "all_cleaning_overall":
# Data cleaning
@ -26,8 +22,14 @@ else:
if calc_windows:
window_features, second_order_features = fetch_provider_features(provider, provider_key, sensor_key, sensor_data_files, time_segments_file, calc_windows=True)
second_order_features.to_csv(snakemake.output[0], index=False)
# Z-score SO features by columns
if provider["WINDOWS"].get("STANDARDIZE_SO_FEATURES", False):
second_order_features[second_order_features.columns[4:]] = StandardScaler().fit_transform(second_order_features[second_order_features.columns[4:]])
window_features.to_csv(snakemake.output[1], index=False)
second_order_features.to_csv(snakemake.output[0], index=False)
elif "empatica" in sensor_key:
pd.DataFrame().to_csv(snakemake.output[1], index=False)