You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
=> I was wrong, they don't adapt it to BART, they just use it for linear regression. So now we don't know if this algorithm can be adapted at all to BART, even before considering the mixed binary-continuous variant.
How to support missing outcome components
New: In the easy case with no correlations first (@Gattocrucco)
I guess this requires messing with the leaves, while the above just touches the outcome layer
Right now we need only missing continuous outcomes, if supporting missing binary outcomes turns out to be a problem, drop it
This PR does not add functionality; it just changes the interfaces to make them forward-compatible with the additions, such that other work can continue in parallel after this PR
This PR changes at once the low-level and high-level interfaces
Low-level interface in mcmcstep
Replace State.y with State.binary_y, because y is actually used only in the binary case
In the continuous case, State.binary_y is set to None
init() now always wants as input a float y, no boolean allowed. For binary, the convention is that y != 0 means True, as usual in Python and C
init() stores binary_y as booleans though, binary_y is always booleans because that's what's needed in step_z
To specify whether regression is binary or continuous, init() has a new parameter outcome_type: OutcomeType = 'continuous'
OutcomeType is an Enum with two string values 'continuous' and 'binary'
High-level interface Bart
type is replaced by outcome_type, the same format used in the low-level interface
y_train is always floats, like in the low-level interface
Drop the x_test parameter from __init__
Drop all prediction attributes: yhat_train, prob_test, etc.
The x_test argument of Bart.predict can be also be the string 'train' to use x_train
Bart.predict() as an additional parameter format: PredictFormat = 'mean'
PredictFormat is a string-valued Enum with values 'mean', 'mean_samples', 'outcome_samples', 'latent_samples'
Example to understand what these settings mean: in the binary case, 'latent_samples' will return ndpost x m samples of the sum-of-trees, 'mean_samples' squashes the sum-of-trees with probit, 'outcome_samples' samples binary outcomes based on the probability in 'mean_samples', and 'mean' is the (m,) vector of averages of mean_samples that gives the posterior mean conditional on a given X.
Again without correlations first because it's easier
outcome_type in init() can also have type Sequence[OutcomeType], matching the number of outcomes in y
State.z and State.binary_y have only as many rows as the number of 'binary' outcome components, or are None if there are none
State has a new attribute binary_indices, as long as the number of binary components, with the indices of the binary components in the list of all components; this attribute is filled in by init() and used by step_z to update only those rows of resid that correspond to binary outcomes
init() enforces that error_cov_scale is diagonal with error_if
The rows/columns in error_cov_scale corresponding to binary outcomes are ignored
error_cov_inv is still stored as a matrix but it's always diagonal
step_error_cov_inv_uv is repeated for all continuous outcomes
It's used in Goh et al. (2024) "Joint Model for Handling..." that adapt it to BART already, their code is https://github.com/yongchengoh/missBART.mcmcstepState.ywithState.binary_y, becauseyis actually used only in the binary caseState.binary_yis set toNoneinit()now always wants as input a floaty, no boolean allowed. For binary, the convention is thaty != 0meansTrue, as usual in Python and Cinit()storesbinary_yas booleans though,binary_yis always booleans because that's what's needed instep_zinit()has a new parameteroutcome_type: OutcomeType = 'continuous'OutcomeTypeis anEnumwith two string values'continuous'and'binary'Barttypeis replaced byoutcome_type, the same format used in the low-level interfacey_trainis always floats, like in the low-level interfacex_testparameter from__init__yhat_train,prob_test, etc.x_testargument ofBart.predictcan be also be the string'train'to usex_trainBart.predict()as an additional parameterformat: PredictFormat = 'mean'PredictFormatis a string-valuedEnumwith values 'mean', 'mean_samples', 'outcome_samples', 'latent_samples'(m,)vector of averages ofmean_samplesthat gives the posterior mean conditional on a given X.mc_gbartBartmcmcstep, without correlations (@Gattocrucco, Multivariate binary support inmcmcstep#99 )step_z, simply vmap over outcome componentmcmcstep, without correlations (@Gattocrucco, Mixed binary-continuous outcomes w/o correlations, internals only #100)outcome_typeininit()can also have typeSequence[OutcomeType], matching the number of outcomes inyState.zandState.binary_yhave only as many rows as the number of 'binary' outcome components, or areNoneif there are noneStatehas a new attributebinary_indices, as long as the number of binary components, with the indices of the binary components in the list of all components; this attribute is filled in byinit()and used bystep_zto update only those rows ofresidthat correspond to binary outcomesinit()enforces thaterror_cov_scaleis diagonal witherror_iferror_cov_scalecorresponding to binary outcomes are ignorederror_cov_invis still stored as a matrix but it's always diagonalstep_error_cov_inv_uvis repeated for all continuous outcomesBartinterface (@Gattocrucco, Expose multivariate binary features in the high-level interface #103)mcmcstep, with correlations (@miaoqingyu2)mcmcstep, with correlations (@miaoqingyu2)Bartinterface (@Gattocrucco)mcmcstep, with correlations (@miaoqingyu2)Bartinterface (@Gattocrucco)