Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasmarwitz committed Dec 13, 2024
1 parent 4ab14a3 commit a5a6fc3
Show file tree
Hide file tree
Showing 11 changed files with 1,550 additions and 71 deletions.
182 changes: 174 additions & 8 deletions docs/examples/example_data_generation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,124 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-26T14:13:33.556121Z",
"iopub.status.busy": "2024-11-26T14:13:33.556025Z",
"iopub.status.idle": "2024-11-26T14:13:34.685096Z",
"shell.execute_reply": "2024-11-26T14:13:34.684830Z"
},
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" <th>6</th>\n",
" <th>7</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>-0.432580</td>\n",
" <td>-1.956691</td>\n",
" <td>-2.724410</td>\n",
" <td>-4.051359</td>\n",
" <td>-4.275785</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.213119</td>\n",
" <td>-1.794246</td>\n",
" <td>3.335272</td>\n",
" <td>0.596448</td>\n",
" <td>-8.053070</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>-0.333022</td>\n",
" <td>-1.855324</td>\n",
" <td>2.567406</td>\n",
" <td>-0.507977</td>\n",
" <td>-7.255018</td>\n",
" <td>2</td>\n",
" <td>4</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>-1.036547</td>\n",
" <td>-1.379920</td>\n",
" <td>1.721547</td>\n",
" <td>-2.817249</td>\n",
" <td>-4.626411</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>-1.514100</td>\n",
" <td>-3.060547</td>\n",
" <td>-4.077247</td>\n",
" <td>-5.819707</td>\n",
" <td>-4.468868</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1 2 3 4 5 6 7\n",
"0 -0.432580 -1.956691 -2.724410 -4.051359 -4.275785 0 2 3\n",
"1 0.213119 -1.794246 3.335272 0.596448 -8.053070 0 2 3\n",
"2 -0.333022 -1.855324 2.567406 -0.507977 -7.255018 2 4 3\n",
"3 -1.036547 -1.379920 1.721547 -2.817249 -4.626411 2 3 1\n",
"4 -1.514100 -3.060547 -4.077247 -5.819707 -4.468868 5 0 3"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from metalearners.data_generation import generate_covariates\n",
"\n",
Expand Down Expand Up @@ -89,13 +200,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-26T14:13:34.704946Z",
"iopub.status.busy": "2024-11-26T14:13:34.704791Z",
"iopub.status.idle": "2024-11-26T14:13:34.707624Z",
"shell.execute_reply": "2024-11-26T14:13:34.707391Z"
},
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"(numpy.ndarray, array([0, 1]), 0.514)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"from metalearners.data_generation import generate_treatment\n",
Expand Down Expand Up @@ -125,13 +253,36 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-26T14:13:34.708926Z",
"iopub.status.busy": "2024-11-26T14:13:34.708830Z",
"iopub.status.idle": "2024-11-26T14:13:34.713643Z",
"shell.execute_reply": "2024-11-26T14:13:34.713435Z"
},
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"array([[-4.6390948 , -6.99101697],\n",
" [-4.5927874 , -1.43775422],\n",
" [-5.6179741 , -3.62754599],\n",
" ...,\n",
" [-5.81369594, -2.16523526],\n",
" [ 0.89106589, 0.44998321],\n",
" [-6.62191898, -7.66198481]])"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from metalearners._utils import get_linear_dimension\n",
"from metalearners.outcome_functions import linear_treatment_effect\n",
Expand Down Expand Up @@ -161,8 +312,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"execution": {
"iopub.execute_input": "2024-11-26T14:13:34.714879Z",
"iopub.status.busy": "2024-11-26T14:13:34.714797Z",
"iopub.status.idle": "2024-11-26T14:13:34.716540Z",
"shell.execute_reply": "2024-11-26T14:13:34.716345Z"
},
"vscode": {
"languageId": "plaintext"
}
Expand All @@ -180,7 +337,16 @@
],
"metadata": {
"language_info": {
"name": "python"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/example_estimating_ates.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### `econML`: `LinearDRLearner`"
"### econML: `LinearDRLearner`"
]
},
{
Expand Down
Loading

0 comments on commit a5a6fc3

Please sign in to comment.