Skip to content

Conversation

@miaoqingyu2
Copy link
Contributor

@miaoqingyu2 miaoqingyu2 commented Jan 3, 2026

I've got the multivariate logic running and passing the linter (for now I’m using # noqa to call a few internal helpers).

At the moment, MvBart reuses some private methods from Bart. I am thinking about either 1.factoring shared pieces into a public BaseBart (so Bart and MvBart inherit from it), or 2. extending Bart directly to support both univariate and multivariate cases. Which way do you prefer?

I still need to add some unit tests on convergence and sanity checks. will do it soon.

@Gattocrucco
Copy link
Collaborator

Gattocrucco commented Jan 4, 2026

Do everything in Bart, I guess it should be possible by adding a few helper methods.

P.S.: If you find it easier, make a completely separate version work like you are doing right now, then we can merge them together later.

@Gattocrucco
Copy link
Collaborator

Gattocrucco commented Jan 4, 2026

Btw I'm about to merge #62 which, amongst other things, adds multivariate support throughout bartz.grove and bartz.mcmcloop, please keep my version when you merge.

@Gattocrucco Gattocrucco linked an issue Jan 4, 2026 that may be closed by this pull request
@miaoqingyu2
Copy link
Contributor Author

Do everything in Bart, I guess it should be possible by adding a few helper methods.

P.S.: If you find it easier, make a completely separate version work like you are doing right now, then we can merge them together later.

I've move everything to Bart. btw just curious why in your mcmcloop. evaluate_trace function the outputed y is of dimension n*k? i thought you would prefer k first.

@Gattocrucco
Copy link
Collaborator

Ach right, I flipped them, I'm going to fix that.

Copy link
Collaborator

@Gattocrucco Gattocrucco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quickly read your code and just noted down the easy things I could notice immediately, I still haven't checked the thing in detail.

offset: FloatLike | None = None,
lamda: FloatLike | None = None, # to change?
tau_num: FloatLike | None = None, # to change?
offset: FloatLike | None = None, # to change?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For offset: also support shape (k,)

Comment on lines +302 to +303
lamda: FloatLike | None = None, # to change?
tau_num: FloatLike | None = None, # to change?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For lambda and tau_num: try to work out a good multivariate generalization of this thing.

I guess tau_num can be a scalar, with leaf_prior_cov_inv just being 1/sigma_mu^2 on the diagonal, that part is fine as is.

For error_cov_scale you do multivariate linear regression and get the estimate of the error cov matrix, but then what to do with the chisquared quantile thing used for univariate? I guess there should be something with the maximum eigenvalue of the error covariance matrix, i.e., set the quantile on the weighted outcome average with the largest residual variance.

I haven't read in detail your code so maybe you've already done the above, but I need to go to bed now.

Copy link
Contributor Author

@miaoqingyu2 miaoqingyu2 Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For lambda and tau_num: try to work out a good multivariate generalization of this thing.

I guess tau_num can be a scalar, with leaf_prior_cov_inv just being 1/sigma_mu^2 on the diagonal, that part is fine as is.

For error_cov_scale you do multivariate linear regression and get the estimate of the error cov matrix, but then what to do with the chisquared quantile thing used for univariate? I guess there should be something with the maximum eigenvalue of the error covariance matrix, i.e., set the quantile on the weighted outcome average with the largest residual variance.

I haven't read in detail your code so maybe you've already done the above, but I need to go to bed now.

For tau_num: Currently, I allow it to be a vector (length $k$) calculated based on the range of each response dimension individually. This allows the leaf node variance to scale differently for each output if needed.

For error_cov_scale: I currently mimic the univariate logic for each dimension independently. I run the standard quantile calibration on each row of $y$ to get specific $\lambda$ values and place them on the diagonal of the prior matrix. It's just because I wanted to ensure that if $k=1$, the multivariate initialization path yields the exact same priors as the existing univariate path.

However, I was also thinking about using the info from eigenvalues and make the scale matrix reveal some info about correlation of y's. Any preference or comments?

@Gattocrucco
Copy link
Collaborator

I merged #64 which created some conflicts with you, sorry! Most of the conflicts look easy to solve, the only tricky one is _predict(). The new version from main is simpler (it does not use the auxiliary _blahblah_chain methods), but you'll have to adapt it again. collapse(out, 0, -1) merges the chain with the sample axes, it means "merge all axes from 0 (included) to -1 (excluded)", i.e., "merge all axes but the last", so it's not already ok for the multivariate version.

@miaoqingyu2
Copy link
Contributor Author

I merged #64 which created some conflicts with you, sorry! Most of the conflicts look easy to solve, the only tricky one is _predict(). The new version from main is simpler (it does not use the auxiliary _blahblah_chain methods), but you'll have to adapt it again. collapse(out, 0, -1) merges the chain with the sample axes, it means "merge all axes from 0 (included) to -1 (excluded)", i.e., "merge all axes but the last", so it's not already ok for the multivariate version.

i changed it to collapse(out, 0, 2) so that it works for both cases

@Gattocrucco
Copy link
Collaborator

Hi, I merged #72 which created a small conflict! Please drop self.ndpost = ... as ndpost is now a property instead of an attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Implementation Plan for Multivariate BART Support

2 participants