Repository navigation
Outcome, and Surv's columns named by role, for 0.3.0 - #5
Merged
Merged
Conversation
- Outcome(response, **columns): each keyword names an output column, taken from a column of X as it is (a categorical keeps its labels) or from a single-column feature fit as a term, e.g. log(exposure). The response's columns come first. - wildcard(exclude=outcome) leaves out every column it uses. - transform(X, response=False) builds only the other columns, e.g. the offset of new data. - With Binomial(output='proportion') the trials are the column weight, times any weights given. - Surv names its columns by role: start, stop, status. - Dataframes of other backends keep categorical columns (polars Enum). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Candidate for 0.3.0, so glmstar can build
ywithOutcomeand find its columns by name.Outcome(response, **columns). Each keyword names an output column, so an estimator can find it by name:stratakeeps its labels), or a single-column feature fit as a term, e.g. R'soffset(log(exposure))as aderived_featurewith a log transform. A feature with more than one column raises.Surv,BinomialorMultinomial, or a plain column. Its columns come first, then the others in keyword order. A name used twice raises.transform(X, response=False)builds only the other columns, e.g. the offset of new data forpredict(X, offset=...).Binomial(..., output='proportion'), the trials become the columnweight, multiplied by anyweight=given (R's prior weights of a proportion).Breaking:
Survnames its columns by role,start,stopandstatus(R's names, and lifelines' defaults for time-varying Cox), not after the data's columns. SoSurv('time', 'status')now givesstopandstatus.Also: polars and pyarrow output keeps categorical columns (as a polars
Enum; pyarrow has none, so strings there).Tests:
tests/test_outcome.py. A Poisson GLM withoffset=log(exposure)and a stratifiedPHRegwith an offset match statsmodels fit directly on the data. Also covered: proportion weights, the offset of new data, errors, arrays, polars and pyarrow. The full suite gives 276 passed and 5 strict xfails.Docs: an
Outcomesection on the responses page, executed locally.For glmstar: default
offset_id,weight_idand theCoxFamilyids tooffset,weight,start,stop,statusandstrata, soCoxNet().fit(X, y)works directly.🤖 Generated with Claude Code