Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/microplex_us/pipelines/pe_native_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ def infer_pe_native_target_unit(target_name: str) -> str:
return "households"
if any(part in {"amount", "total"} for part in parts):
return "dollars"
if (
len(parts) >= 3
and parts[0] == "nation"
and parts[1] == "cbo"
and parts[2] == "income_by_source"
):
return "dollars"
if any(part in {"count", "returns", "filers"} for part in parts):
return "returns"
if "spending" in normalized or "cost" in normalized or "tax" in normalized:
Expand Down
23 changes: 23 additions & 0 deletions tests/pipelines/test_pe_native_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from microplex_us.pipelines.pe_native_loss import (
build_pe_native_loss_arrays,
infer_pe_native_target_unit,
pe_native_huber_loss,
pe_native_huber_loss_terms,
)
Expand All @@ -32,6 +33,28 @@ def test_bucketed_loss_downweights_tiny_baseline_outlier() -> None:
assert terms[1] > terms[0]


def test_cbo_income_by_source_filers_targets_are_dollars() -> None:
assert (
infer_pe_native_target_unit(
"nation/cbo/income_by_source/self_employment_income/filers"
)
== "dollars"
)
assert (
infer_pe_native_target_unit(
"nation/cbo/income_by_source/taxable_interest_income+"
"non_qualified_dividend_income/filers"
)
== "dollars"
)
assert (
infer_pe_native_target_unit(
"nation/irs/adjusted gross income/count/AGI in 0-25k/taxable/All"
)
== "returns"
)


def test_robust_pe_native_optimizer_uses_huber_objective() -> None:
matrix = np.asarray([[1.0, 0.0], [0.0, 1.0]])
target = np.asarray([1.0, 1.0])
Expand Down
Loading