From 7543011bdcce96987fd539a0ab3cccd83c3c9f50 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 22 Jul 2024 16:11:30 -0400 Subject: [PATCH] Added __init__ scripts for logic directory --- reweight/__init__.py | 3 +- reweight/data/__init__.py | 1 - reweight/logic/__init__.py | 2 +- reweight/tests/__init__.py | 1 - reweight/tests/test_uk_prototype.py | 2 +- test.ipynb | 48 +++++++++++++++++++++++++++++ 6 files changed, 52 insertions(+), 5 deletions(-) delete mode 100644 reweight/data/__init__.py delete mode 100644 reweight/tests/__init__.py diff --git a/reweight/__init__.py b/reweight/__init__.py index 3dc1f76..28fe9cc 100644 --- a/reweight/__init__.py +++ b/reweight/__init__.py @@ -1 +1,2 @@ -__version__ = "0.1.0" +__version__ = "0.3.0" +from .logic.reweight import reweight diff --git a/reweight/data/__init__.py b/reweight/data/__init__.py deleted file mode 100644 index badcc11..0000000 --- a/reweight/data/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .reweight import reweight \ No newline at end of file diff --git a/reweight/logic/__init__.py b/reweight/logic/__init__.py index badcc11..a9de83b 100644 --- a/reweight/logic/__init__.py +++ b/reweight/logic/__init__.py @@ -1 +1 @@ -from .reweight import reweight \ No newline at end of file +from .reweight import reweight diff --git a/reweight/tests/__init__.py b/reweight/tests/__init__.py deleted file mode 100644 index badcc11..0000000 --- a/reweight/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .reweight import reweight \ No newline at end of file diff --git a/reweight/tests/test_uk_prototype.py b/reweight/tests/test_uk_prototype.py index bb08678..dc69b2b 100644 --- a/reweight/tests/test_uk_prototype.py +++ b/reweight/tests/test_uk_prototype.py @@ -30,4 +30,4 @@ def test_uk_prototype(): ) = generate_model_variables("frs_2021", 2025) sim_matrix = torch.tensor(values_df.to_numpy(), dtype=torch.float32) - reweight.reweight(household_weights, sim_matrix, targets, targets_array) + reweight(household_weights, sim_matrix, targets, targets_array) diff --git a/test.ipynb b/test.ipynb index c219280..e346cd3 100644 --- a/test.ipynb +++ b/test.ipynb @@ -76,6 +76,54 @@ "# square error, and then average to get MSE." ] }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "from reweight.logic import reweight" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Epoch 100, Loss: 48.30685043334961\n", + "Epoch 200, Loss: 40.58155059814453\n", + "Epoch 300, Loss: 34.585235595703125\n", + "Epoch 400, Loss: 29.832853317260742\n", + "Epoch 500, Loss: 25.99891471862793\n", + "Epoch 600, Loss: 22.858182907104492\n", + "Epoch 700, Loss: 20.250896453857422\n", + "Epoch 800, Loss: 18.061073303222656\n", + "Epoch 900, Loss: 16.202829360961914\n", + "Epoch 1000, Loss: 14.611446380615234\n" + ] + }, + { + "data": { + "text/plain": [ + "tensor([1120.1953, 89.4442, 3851.2649, ..., 730.9640, 832.0632,\n", + " 4155.2686])" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sim_matrix = torch.tensor(values_df.to_numpy(), dtype=torch.float32)\n", + "\n", + "reweight.reweight(household_weights, sim_matrix, targets, targets_array)" + ] + }, { "cell_type": "code", "execution_count": 29,