Skip to content

Commit

Permalink
Added __init__ scripts for logic directory
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jul 22, 2024
1 parent 349d707 commit 7543011
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 5 deletions.
3 changes: 2 additions & 1 deletion reweight/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__version__ = "0.1.0"
__version__ = "0.3.0"
from .logic.reweight import reweight
1 change: 0 additions & 1 deletion reweight/data/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion reweight/logic/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .reweight import reweight
from .reweight import reweight
1 change: 0 additions & 1 deletion reweight/tests/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion reweight/tests/test_uk_prototype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
48 changes: 48 additions & 0 deletions test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7543011

Please sign in to comment.