Refine cpm_spec() with helper-based screening, weighting, and modeling#54
Refine cpm_spec() with helper-based screening, weighting, and modeling#54
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #54 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 12 12
Lines 970 1327 +357
==========================================
+ Hits 970 1327 +357 ☔ View full report in Codecov by Sentry. |
d3b69c1 to
0c0b9f0
Compare
|
I think the next implementation step is less about adding more options to What seems most promising to me is a two-stage CPM design:
Concretely, that suggests a future shape more like: cpm_spec(
screen = cpm_screen(...),
feature_space = "separate",
weighting = cpm_weighting(...),
model = cpm_model_lm()
)The key implementation idea is that Stage 1 remains the CPM-specific core: That means:
One important naming point from the current API discussion:
I also think this would help preserve the meaning of
That is another reason I would keep the first model expansion limited to So if we want an incremental path, my suggestion would be:
That would keep the current PR focused, while giving the next round of API work |
Summary
This draft PR refines the native
cpm_spec()API around a clearer staged mental model while keeping the current CPM prediction structure intact.The key clarification in this version is that the Stage 1 predictors currently exposed by the package are CPM-derived network-strength predictors:
positiveedges define apositive_strengthnegativeedges define anegative_strengthfeature_space = "separate"exposes those strengths directlyfeature_space = "net"exposes onenet_strength = positive_strength - negative_strengthStage 2 is now explicit via
model = cpm_model_lm(), but remains intentionally minimal in this PR.The public surface is now:
Helper constructors now cover the parts that naturally belong together:
screen = cpm_screen(...)with thresholds built bycpm_threshold()weighting = cpm_weighting(...)model = cpm_model_lm()This PR also keeps weighted CPM summaries via sigmoid edge weights centered on the fold-local threshold.
Implementation work previously tracked in #50 and #51 is now covered here. The older
prediction_headextension thread from #52 has been superseded by #55.Refs #44
Refs #50
Refs #51
Refs #55
What Changed
prediction_headargument with an explicitmodel = cpm_model_lm()helpernetwork_summarytofeature_spaceso the API matches what this stage really controlspositive/negativerefer to screened positive- and negative-association edge setsseparateexposespositive_strengthandnegative_strengthjointis the classic model stream that uses both strengths togethernetis the single-stream view overnet_strengthcombinedtojointdifferencetonet, while keeping the internal single-feature column explicit asnet_strengthpearson/spearmanscreeningalpha/sparsity/effect_sizethresholdingbinary/sigmoidedge weightingseparate/netfeature constructionjoint-stream regression path when one strength column is degenerateNotes For Review
return_edgesstill reports the hard-thresholded positive / negative masksfit_obj$model$edge_weightsmodel = cpm_model_lm()is deliberately minimal in this PR: the goal here is to establish the Stage 2 API seam without yet expanding model familiesfit_obj$model$outcome_models, with the active stream names recorded infit_obj$model$prediction_streamsReprexes
The examples below were generated on this branch.
1. Default CPM with the staged helper surface
2. Rich screening with an explicit model helper
3. Weighted CPM with
cpm_weighting()4. Resampling with the same staged spec object
Validation
air format --check R testsdevtools::document()devtools::test()locallycovr::package_coverage(type = "tests")devtools::check()is currently blocked in this environment by missing Pandoc for vignette rebuilding; fallback localR CMD checkon a tarball built with--no-build-vignettesreturned 0 errors, 2 warnings, and 0 notes, where both warnings reflect skipped vignette outputs