Refactor the rule phone_locations_add_doryab_extra_columns

feature/aware_sql_split
Meng Li 2021-05-28 09:48:36 -04:00
parent 91a767699d
commit 9687081fbe
2 changed files with 12 additions and 18 deletions

View File

@ -370,15 +370,7 @@ rule phone_locations_add_doryab_extra_columns:
input: input:
sensor_input = "data/interim/{pid}/phone_locations_processed_with_datetime.csv", sensor_input = "data/interim/{pid}/phone_locations_processed_with_datetime.csv",
params: params:
accuracy_limit = config["PHONE_LOCATIONS"]["PROVIDERS"]["DORYAB"]["ACCURACY_LIMIT"], provider = config["PHONE_LOCATIONS"]["PROVIDERS"]["DORYAB"]
maximum_row_gap = config["PHONE_LOCATIONS"]["PROVIDERS"]["DORYAB"]["MAXIMUM_ROW_GAP"],
dbscan_eps = config["PHONE_LOCATIONS"]["PROVIDERS"]["DORYAB"]["DBSCAN_EPS"],
dbscan_minsamples = config["PHONE_LOCATIONS"]["PROVIDERS"]["DORYAB"]["DBSCAN_MINSAMPLES"],
threshold_static = config["PHONE_LOCATIONS"]["PROVIDERS"]["DORYAB"]["THRESHOLD_STATIC"],
clustering_algorithm = config["PHONE_LOCATIONS"]["PROVIDERS"]["DORYAB"]["CLUSTERING_ALGORITHM"],
cluster_on = config["PHONE_LOCATIONS"]["PROVIDERS"]["DORYAB"]["CLUSTER_ON"],
infer_home_location_strategy = config["PHONE_LOCATIONS"]["PROVIDERS"]["DORYAB"]["INFER_HOME_LOCATION_STRATEGY"],
minimum_days_to_detect_home_changes = config["PHONE_LOCATIONS"]["PROVIDERS"]["DORYAB"]["MINIMUM_DAYS_TO_DETECT_HOME_CHANGES"]
output: output:
"data/interim/{pid}/phone_locations_processed_with_datetime_with_doryab_columns.csv" "data/interim/{pid}/phone_locations_processed_with_datetime_with_doryab_columns.csv"
script: script:

View File

@ -104,15 +104,17 @@ def infer_home_location(location_data, clustering_algorithm, hyperparameters, st
location_data = pd.read_csv(snakemake.input["sensor_input"]) location_data = pd.read_csv(snakemake.input["sensor_input"])
accuracy_limit = snakemake.params["accuracy_limit"] provider = snakemake.params["provider"]
maximum_row_gap = snakemake.params["maximum_row_gap"]
dbscan_eps = snakemake.params["dbscan_eps"] accuracy_limit = provider["ACCURACY_LIMIT"]
dbscan_minsamples = snakemake.params["dbscan_minsamples"] maximum_row_gap = provider["MAXIMUM_ROW_GAP"]
threshold_static = snakemake.params["threshold_static"] dbscan_eps = provider["DBSCAN_EPS"]
clustering_algorithm = snakemake.params["clustering_algorithm"] dbscan_minsamples = provider["DBSCAN_MINSAMPLES"]
cluster_on = snakemake.params["cluster_on"] threshold_static = provider["THRESHOLD_STATIC"]
strategy = snakemake.params["infer_home_location_strategy"] clustering_algorithm = provider["CLUSTERING_ALGORITHM"]
days_threshold = snakemake.params["minimum_days_to_detect_home_changes"] cluster_on = provider["CLUSTER_ON"]
strategy = provider["INFER_HOME_LOCATION_STRATEGY"]
days_threshold = provider["MINIMUM_DAYS_TO_DETECT_HOME_CHANGES"]
rows_before_accuracy_filter = len(location_data) rows_before_accuracy_filter = len(location_data)
location_data = location_data[location_data["accuracy"] < accuracy_limit] location_data = location_data[location_data["accuracy"] < accuracy_limit]