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

Pandas based logistic regression #316

Merged
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
try explicitly broadcasting
Signed-off-by: Henry D <[email protected]>
  • Loading branch information
henrydavidge committed Dec 21, 2020
commit fd2edd07dddfec1279c5fcb2da699d55a91fe67b
19 changes: 15 additions & 4 deletions python/glow/gwas/log_reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,24 @@ def logistic_regression(
Y, phenotype_df, offset_df,
lambda y, pdf, odf: _create_log_reg_state(y, pdf, odf, C, Y_mask))

sc = genotype_df.sql_ctx.sparkSession.sparkContext
bc_state = sc.broadcast(state)
bc_C = sc.broadcast(C)
bc_Y_mask = sc.broadcast(Y_mask.astype(dt))

map_func = make_map_func(bc_state, bc_C, bc_Y_mask, correction,
phenotype_df.columns.to_series().astype('str'))

return genotype_df.mapInPandas(map_func, result_struct)


def make_map_func(bc_state, bc_C, bc_Y_mask, correction, column_names):
def map_func(pdf_iterator):
for pdf in pdf_iterator:
yield gwas_fx._loco_dispatch(pdf, state, _logistic_regression_inner, C,
Y_mask.astype(np.float64), correction,
phenotype_df.columns.to_series().astype('str'))
yield gwas_fx._loco_dispatch(pdf, bc_state.value, _logistic_regression_inner,
bc_C.value, bc_Y_mask.value, correction, column_names)

return genotype_df.mapInPandas(map_func, result_struct)
return map_func


@typechecked
Expand Down