Move and rename target variable.

labels
junos 2022-04-06 18:21:09 +02:00
parent 50c0defca7
commit 7ff3dcf5fc
1 changed files with 3 additions and 2 deletions

View File

@ -12,9 +12,10 @@ target_variable_name = esm_names.str.contains(snakemake.params["target_variable"
if all(~target_variable_name): if all(~target_variable_name):
raise ValueError("The requested target (", snakemake.params["target_variable"], ")cannot be found in the dataset.", raise ValueError("The requested target (", snakemake.params["target_variable"], ")cannot be found in the dataset.",
"Please check the names of phone_esm_ columns in all_sensor_features_cleaned_rapids.csv") "Please check the names of phone_esm_ columns in all_sensor_features_cleaned_rapids.csv")
esm_names = esm_names[~target_variable_name]
# We will only keep one column related to phone_esm and that will be our target variable.
model_input = cleaned_sensor_features.drop(esm_names, axis=1) model_input = cleaned_sensor_features.drop(esm_names, axis=1)
model_input["target"] = cleaned_sensor_features[esm_names[target_variable_name]]
# We will only keep one column related to phone_esm and that will be our target variable.
# Add it back to the very and of the data frame and rename it to target.
model_input.to_csv(snakemake.output[0], index=False) model_input.to_csv(snakemake.output[0], index=False)