Skip to content

Conversation

@baogorek
Copy link
Collaborator

@baogorek baogorek commented May 2, 2025

Using just age demographics, the loss function is running using CPS 2022

Loss: 0.011413061991333961, Epoch: 392
Loss: 0.011327974498271942, Epoch: 393
Loss: 0.011243709363043308, Epoch: 394
Loss: 0.011160251684486866, Epoch: 395
Loss: 0.011077594943344593, Epoch: 396
Loss: 0.010995729826390743, Epoch: 397
Loss: 0.010914644226431847, Epoch: 398
Loss: 0.01083433348685503, Epoch: 399

The weights:

In [83]: weights
Out[83]:
tensor([[10.1206, 18.2286, 20.2968,  ..., 10.7811, 18.6077, 14.4216],
        [10.7241, 18.0689, 19.4778,  ..., 10.7965, 17.4027, 13.6720],
        [11.9334, 19.0865, 17.8811,  ..., 10.6579, 17.5859, 14.8708],
        ...,
        [ 9.1700, 19.5172, 20.2600,  ..., 10.9448, 18.4367, 17.7795],
        [10.7363, 18.7752, 18.6634,  ..., 10.6316, 17.4193, 14.7576],
        [ 9.5410, 16.5121, 11.7511,  ...,  7.3818, 14.1645, 12.1111]],
       requires_grad=True)

In [84]: weights.shape
Out[84]: torch.Size([435, 20879])

I have some outstanding conceptual questions:

  • Do I need a mask matrix? If so, how would that work?
  • Why were the weights transformed by the exp function in *-uk-data?

@nikhilwoodruff
Copy link
Contributor

@baogorek thanks for this! To your questions:

  1. I don't think we need a mask matrix for this- how were you thinking about this?
  2. Ah yes- so we should actually calibrate the log of the weights rather than the weights themselves- this means we don't have to worry about negative weights.

@baogorek
Copy link
Collaborator Author

baogorek commented May 2, 2025

@baogorek thanks for this! To your questions:

  1. I don't think we need a mask matrix for this- how were you thinking about this?
  2. Ah yes- so we should actually calibrate the log of the weights rather than the weights themselves- this means we don't have to worry about negative weights.

Thanks, @nikhilwoodruff . (Heads up that I heavily edited this comment a few hours after leaving it, in case you skimmed it earlier.)

  1. I see that in *-uk-data there are different countries and no target should be constructed from weights from a different country. So I don't think there's the need for a mask here either. Perhaps for different states?

  2. Ah, yeah, thanks. I was thinking it was a probability normalization.

One follow up regarding the optimization mechanics, I'm currently able to use the uncommented version of the relative mse:

        # mse = torch.mean((pred / (1 + y) - 1) ** 2)
        mse = torch.mean(((pred - y) / y) ** 2)   

I realize that the first formulation is to protect against cases where y is zero. But would that ever happen? Technically the first equation measures the squared relative distance to a modified target: 1 + y instead of y. Given these numbers are so large, it probably doesn't matter, but then they wouldn't be zero either. Not a show shopper at the moment in any case.

Next: I will move to state and national targets unless I hear otherwise. Again, let me know if state masking is a thing to worry about.

@nikhilwoodruff
Copy link
Contributor

Thanks Ben! Replies below.

  1. I see that in *-uk-data there are different countries and no target should be constructed from weights from a different country. So I don't think there's the need for a mask here either. Perhaps for different states?

Sorry yes- we shouldn't have records from different states have weight for congressional districts outside their states. So we'll need to add the mask actually, you're right.

I realize that the first formulation is to protect against cases where y is zero. But would that ever happen?

In the UK, some targets are zero for some years. We actually used to do reweighting for future years too, and we have some targeted benefits that are being phased out and roll down to zero claimants. But yes probably doesn't apply here.

@baogorek
Copy link
Collaborator Author

baogorek commented May 9, 2025

This is now its own repo

@baogorek baogorek closed this May 9, 2025
@baogorek baogorek deleted the districts branch July 18, 2025 21:10
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.

3 participants