Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
manandraj20 committed Nov 14, 2024
2 parents 754bd7c + 026cac0 commit 8a5a554
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
python-version: '3.11'

- name: Install dependencies
run: |
Expand Down
113 changes: 64 additions & 49 deletions demo_final_contact_matrix.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -49,10 +49,10 @@
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>ID</th>\n",
" <th>date</th>\n",
" <th>merch_category</th>\n",
" <th>merch_postal_code</th>\n",
" <th>transaction_type</th>\n",
" <th>date</th>\n",
" <th>spendamt</th>\n",
" <th>nb_transactions</th>\n",
" </tr>\n",
Expand All @@ -61,80 +61,80 @@
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>Hospitals</td>\n",
" <td>111921</td>\n",
" <td>ONLINE</td>\n",
" <td>2019-01-01</td>\n",
" <td>80797.323317</td>\n",
" <td>398</td>\n",
" <td>Grocery Stores/Supermarkets</td>\n",
" <td>8700000</td>\n",
" <td>ONLINE</td>\n",
" <td>11238.128450</td>\n",
" <td>160</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>Bars/Discotheques</td>\n",
" <td>050025</td>\n",
" <td>OFFLINE</td>\n",
" <td>1</td>\n",
" <td>2019-01-01</td>\n",
" <td>5331.031100</td>\n",
" <td>283</td>\n",
" <td>Grocery Stores/Supermarkets</td>\n",
" <td>500034</td>\n",
" <td>ONLINE</td>\n",
" <td>12848.165221</td>\n",
" <td>183</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2</td>\n",
" <td>Bars/Discotheques</td>\n",
" <td>050032</td>\n",
" <td>OFFLINE</td>\n",
" <td>2019-01-01</td>\n",
" <td>5180.722635</td>\n",
" <td>268</td>\n",
" <td>Grocery Stores/Supermarkets</td>\n",
" <td>110621</td>\n",
" <td>ONLINE</td>\n",
" <td>12116.165569</td>\n",
" <td>173</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3</td>\n",
" <td>Drug Stores/Pharmacies</td>\n",
" <td>050012</td>\n",
" <td>OFFLINE</td>\n",
" <td>2019-01-01</td>\n",
" <td>5032.333763</td>\n",
" <td>177</td>\n",
" <td>Hotels/Motels</td>\n",
" <td>8900000</td>\n",
" <td>OFFLINE</td>\n",
" <td>7745.998879</td>\n",
" <td>38</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>3</td>\n",
" <td>Drug Stores/Pharmacies</td>\n",
" <td>050031</td>\n",
" <td>OFFLINE</td>\n",
" <td>4</td>\n",
" <td>2019-01-01</td>\n",
" <td>4899.182326</td>\n",
" <td>150</td>\n",
" <td>Restaurants</td>\n",
" <td>111941</td>\n",
" <td>OFFLINE</td>\n",
" <td>6927.424754</td>\n",
" <td>173</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" ID merch_category merch_postal_code transaction_type date \\\n",
"0 1 Hospitals 111921 ONLINE 2019-01-01 \n",
"1 2 Bars/Discotheques 050025 OFFLINE 2019-01-01 \n",
"2 2 Bars/Discotheques 050032 OFFLINE 2019-01-01 \n",
"3 3 Drug Stores/Pharmacies 050012 OFFLINE 2019-01-01 \n",
"4 3 Drug Stores/Pharmacies 050031 OFFLINE 2019-01-01 \n",
" ID date merch_category merch_postal_code \\\n",
"0 1 2019-01-01 Grocery Stores/Supermarkets 8700000 \n",
"1 1 2019-01-01 Grocery Stores/Supermarkets 500034 \n",
"2 2 2019-01-01 Grocery Stores/Supermarkets 110621 \n",
"3 3 2019-01-01 Hotels/Motels 8900000 \n",
"4 4 2019-01-01 Restaurants 111941 \n",
"\n",
" spendamt nb_transactions \n",
"0 80797.323317 398 \n",
"1 5331.031100 283 \n",
"2 5180.722635 268 \n",
"3 5032.333763 177 \n",
"4 4899.182326 150 "
" transaction_type spendamt nb_transactions \n",
"0 ONLINE 11238.128450 160 \n",
"1 ONLINE 12848.165221 183 \n",
"2 ONLINE 12116.165569 173 \n",
"3 OFFLINE 7745.998879 38 \n",
"4 OFFLINE 6927.424754 173 "
]
},
"execution_count": 3,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = pd.read_csv(r\"C:\\Users\\Milan Anand Raj\\Desktop\\KNOWLEDGEEDGEAI\\PET\\final_data\\final_technical_data.csv\")\n",
"data = pd.read_csv(r'D:\\workspace\\PET\\technical_phase_data.csv')\n",
"data.head()"
]
},
Expand All @@ -147,7 +147,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -167,7 +167,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -184,7 +184,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -193,7 +193,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -357,11 +357,26 @@
"source": [
"estimated_contact_matrix"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"diff = estimated_C \n",
"\n",
"plt.figure(figsize=(10, 8))\n",
"plt.imshow(diff, cmap = 'coolwarm', interpolation='none')\n",
"plt.colorbar(label = 'Diff')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -375,7 +390,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
Binary file removed dist/dp_epidemiology-0.0.9.tar.gz
Binary file not shown.
Binary file not shown.
Binary file added dist/dp_epidemiology-0.1.0.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "DP_epidemiology"
version = "0.0.9"
version = "0.1.0"

dependencies = [
"pandas>=2.1.4",
Expand Down
1 change: 1 addition & 0 deletions src/DP_epidemiology/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,6 @@ def time_preprocess(df):

# Filter the dataframe based on the category
df_final = df_weekly[["date", category]]
df_final[category] = (df_final[category] - df_final[category].min()) / (df_final[category].max() - df_final[category].min())

return df_final

0 comments on commit 8a5a554

Please sign in to comment.