Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imputation manual construction #186

Merged
merged 19 commits into from
May 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix for flake8 failure
  • Loading branch information
vidhyamanisankar committed May 13, 2024

Verified

This commit was signed with the committer’s verified signature.
vidhyamanisankar vidhyamanisankar
commit 7f3789b0eb7f0de7995a9d5d3efc866066f0f30b
17 changes: 10 additions & 7 deletions statistical_methods_library/imputation/engine.py
Original file line number Diff line number Diff line change
@@ -241,7 +241,8 @@ def impute(
"marker": marker_col,
}
# input_df.show(100)
# TODO CHECK in nimpuation wrapper the same column name is avaliable in back data df as well ?!
# TODO CHECK in impuation wrapper the same column name
# is avaliable in back data df as well ?!
if manual_construction_col in input_df.columns:
input_params["manual_const"] = manual_construction_col

@@ -344,16 +345,15 @@ def impute(
# print("only_mc_data")
# only_mc_data.show(100)
# df_with_mc_data.show(100)
# TODO Additionally, after MC data is entered, filter out the immediate missing responses.
# TODO Additionally, after MC data is entered,
# filter out the immediate missing responses.
prepared_df = prepared_df.filter(
~(col("marker") == Marker.MANUAL_CONSTRUCTION.value)
| ~(col("marker") == Marker.FORWARD_IMPUTE_FROM_MANUAL_CONSTRUCTION.value)
)
# print("prepared_df_without_mc_fimc :: ")
# prepared_df.show()
# ["ref", "period", "grouping"]
# mc_join_cont = [mc_df1.marker_mc != Marker.MANUAL_CONSTRUCTION.value , mc_df1.ref == prepared_df.ref, mc_df1.period == prepared_df.period,mc_df1.grouping == prepared_df.grouping]
# mc_df2 = prepared_df.join(mc_df1,mc_join_cont, "left")
# mc_df2.show(100)

# TODO refactor do with one select
@@ -394,7 +394,7 @@ def impute(
)
.join(
prior_period_df, [col("period") == col("prior_period")]
) # TODO check what is the impact to miss the mc column in prior_period_df
) # TODO chek impact to miss the mccolumn in prior_period_df
.drop("prior_period")
.filter(((col(marker_col) != lit(Marker.BACKWARD_IMPUTE.value))))
.withColumn(
@@ -417,9 +417,11 @@ def impute(
== Marker.FORWARD_IMPUTE_FROM_MANUAL_CONSTRUCTION.value
)
)
back_data_mc.show(10)
# print("back_data_mc")
# back_data_mc.show(100)
# TODO Additionally, after MC data is entered, filter out the immediate missing responses.
# TODO Additionally, after MC data is entered,
# filter out the immediate missing responses.
back_data_period_df = back_data_period_df.filter(
~(col("marker") == Marker.MANUAL_CONSTRUCTION.value)
| ~(
@@ -839,7 +841,8 @@ def forward_impute_from_construction(df: DataFrame) -> DataFrame:
):
df = stage(df).localCheckpoint(eager=False)
# df.show(100)
# TODO move thid code after the rotio calculation. So dont need to do multiple times.
# TODO move thid code after the rotio calculation.
# So dont need to do multiple times.
if manual_construction_col in input_df.columns and stage == backward_impute:
# print("after backward_impute add the mc only data")
# only_mc_data.show(100)