From f824fb323606eb3d875b4e678533e9d4627bcd74 Mon Sep 17 00:00:00 2001 From: Phil <15682144+doctor-phil@users.noreply.github.com> Date: Mon, 4 Nov 2024 20:25:29 -0800 Subject: [PATCH] fix ml in econ? --- lectures/applications/ml_in_economics.md | 15 ++++++--------- lectures/tools/maps.md | 1 - 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lectures/applications/ml_in_economics.md b/lectures/applications/ml_in_economics.md index 42c7e3d0..2435711f 100644 --- a/lectures/applications/ml_in_economics.md +++ b/lectures/applications/ml_in_economics.md @@ -13,6 +13,7 @@ kernelspec: **Author** > - [Paul Schrimpf *UBC*](https://economics.ubc.ca/faculty-and-staff/paul-schrimpf/) +> - [Philip Solimine *UBC*](https://www.psolimine.net/) **Prerequisites** @@ -259,11 +260,11 @@ tags: [hide-output] --- cps["female"] = (cps.sex==2) cps["log_earn"] = np.log(cps.earnwke) -cps["log_earn"][np.isinf(cps.log_earn)] = np.nan +cps.loc[np.isinf(cps.log_earn),"log_earn"] = np.nan cps["log_uhours"] = np.log(cps.uhourse) -cps["log_uhours"][np.isinf(cps.log_uhours)] = np.nan +cps.loc[np.isinf(cps.log_uhours),"log_uhours"] = np.nan cps["log_hourslw"] = np.log(cps.hourslw) -cps["log_hourslw"][np.isinf(cps.log_hourslw)] = np.nan +cps.loc[np.isinf(cps.log_hourslw),"log_hourslw"] = np.nan cps["log_wageu"] = cps.log_earn - cps.log_uhours cps["log_wagelw"] = cps.log_earn - cps.log_hourslw @@ -394,12 +395,8 @@ def plotpredictions(pl) : plt.title("Prediction Errors") plt.figure() - sns.distplot(pl[2][female==0], hist = True, kde = False, - kde_kws = {'shade': True, 'linewidth': 3}, - label = "Male") - sns.distplot(pl[2][female==1], hist = True, kde = False, - kde_kws = {'shade': True, 'linewidth': 3}, - label = "Female") + sns.histplot(pl[2][female == 0], bins=30, label="Male", kde=False) + sns.histplot(pl[2][female == 1], bins=30, label="Female", kde=False) plt.title('P(female|x)') plotpredictions(pl_lasso) ``` diff --git a/lectures/tools/maps.md b/lectures/tools/maps.md index f1ce56a7..359cbf5c 100644 --- a/lectures/tools/maps.md +++ b/lectures/tools/maps.md @@ -13,7 +13,6 @@ kernelspec: **Co-author** > - [Kim Ruhl *University of Wisconsin*](http://kimjruhl.com) -> - [Philip Solimine *UBC*](https://www.psolimine.net) **Prerequisites**