Skip to content

Commit

Permalink
Shift to branch of US
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilwoodruff committed Sep 22, 2024
1 parent c35a21c commit 5a3f94d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions policyengine_us_data/datasets/cps/enhanced_cps.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ def train_previous_year_income_model():
df = sim.calculate_dataframe(VARIABLES + OUTPUTS, 2019, map_to="person")
df_train = df[df.previous_year_income_available]

from survey_enhance import Imputation
from policyengine_us_data.utils import QRF

income_last_year = Imputation()
income_last_year = QRF()
X = df_train[VARIABLES[1:]]
y = df_train[OUTPUTS]

income_last_year.train(X, y)
income_last_year.fit(X, y)

return income_last_year

Expand Down
2 changes: 1 addition & 1 deletion policyengine_us_data/datasets/cps/extended_cps.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def generate(self):
y = pd.DataFrame(columns=IMPUTED_VARIABLES, index=X.index)

model = QRF()
model.train(
model.fit(
X_train,
y_train,
)
Expand Down
13 changes: 6 additions & 7 deletions policyengine_us_data/datasets/puf/puf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ def impute_pension_contributions_to_puf(puf_df):
["employment_income", "household_weight", "pre_tax_contributions"]
)

from survey_enhance import Imputation
from policyengine_us_data.utils import QRF

pension_contributions = Imputation()
pension_contributions = QRF()

pension_contributions.train(
pension_contributions.fit(
X=cps_df[["employment_income"]],
Y=cps_df[["pre_tax_contributions"]],
sample_weight=cps_df["household_weight"],
)
return pension_contributions.predict(
X=puf_df[["employment_income"]],
Expand All @@ -39,7 +38,7 @@ def impute_pension_contributions_to_puf(puf_df):
def impute_missing_demographics(
puf: pd.DataFrame, demographics: pd.DataFrame
) -> pd.DataFrame:
from survey_enhance import Imputation
from policyengine_us_data.utils import QRF

puf_with_demographics = (
puf[puf.RECID.isin(demographics.RECID)]
Expand All @@ -63,9 +62,9 @@ def impute_missing_demographics(
"XTOT",
]

demographics_from_puf = Imputation()
demographics_from_puf = QRF()

demographics_from_puf.train(
demographics_from_puf.fit(
X=puf_with_demographics[NON_DEMOGRAPHIC_VARIABLES],
Y=puf_with_demographics[DEMOGRAPHIC_VARIABLES],
)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ dependencies = [
dev = [
"black",
"pytest",
"policyengine_us==1.71.1",
"survey_enhance",
"policyengine_us @ git+https://github.com/policyengine/policyengine-us@us-rent-data",
"quantile-forest",
"torch",
"tables",
"tabulate",
Expand Down

0 comments on commit 5a3f94d

Please sign in to comment.