-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mobility model alpha parameter regression from data #15
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d3a5927
Fixed PR changes for params_regression
tanzim10 fabd34b
Fixed Unittest for param_regression according to PR change
tanzim10 71f6c96
Fixed the mobility notebook and radp_library file(PR changes done)
tanzim10 deb3bc3
Resolved test_param_regression unittest cases
tanzim10 064e285
Updated Param Regression and radp library as instructed in the PR review
tanzim10 f774355
Changed the scipy dependency to solve dependency error
tanzim10 962e4db
Changed how seed value works especially made it user friendly
tanzim10 625be10
Refactored functions and changed the imports
tanzim10 9d507a1
Resolved test_param_regression imports
tanzim10 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,361 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ec7ab4ae", | ||
"metadata": {}, | ||
"source": [ | ||
"# Alpha Optimization in a Gauss-Markov Mobility Model\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "754a70e3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import sys\n", | ||
"from pathlib import Path\n", | ||
"sys.path.append(f\"{Path().absolute().parent}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b3d3ca1a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd\n", | ||
"import scipy\n", | ||
"import numpy as np\n", | ||
"from radp_library import *\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"import matplotlib.cm as cm" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "309ead1f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"params = {\n", | ||
" \"ue_tracks_generation\": {\n", | ||
" \"params\": {\n", | ||
" \"simulation_duration\": 3600,\n", | ||
" \"simulation_time_interval_seconds\": 0.01,\n", | ||
" \"num_ticks\": 50,\n", | ||
" \"num_batches\": 1,\n", | ||
" \"ue_class_distribution\": {\n", | ||
" \"stationary\": {\n", | ||
" \"count\": 10,\n", | ||
" \"velocity\": 0,\n", | ||
" \"velocity_variance\": 1\n", | ||
" },\n", | ||
" \"pedestrian\": {\n", | ||
" \"count\": 5,\n", | ||
" \"velocity\": 2,\n", | ||
" \"velocity_variance\": 1\n", | ||
" },\n", | ||
" \"cyclist\": {\n", | ||
" \"count\": 5,\n", | ||
" \"velocity\": 5,\n", | ||
" \"velocity_variance\": 1\n", | ||
" },\n", | ||
" \"car\": {\n", | ||
" \"count\": 12,\n", | ||
" \"velocity\": 20,\n", | ||
" \"velocity_variance\": 1\n", | ||
" }\n", | ||
" },\n", | ||
" \"lat_lon_boundaries\": {\n", | ||
" \"min_lat\": -90,\n", | ||
" \"max_lat\": 90,\n", | ||
" \"min_lon\": -180,\n", | ||
" \"max_lon\": 180\n", | ||
" },\n", | ||
" \"gauss_markov_params\": {\n", | ||
" \"alpha\": 0.5,\n", | ||
" \"variance\": 0.8,\n", | ||
" \"rng_seed\": 42,\n", | ||
" \"lon_x_dims\": 100,\n", | ||
" \"lon_y_dims\": 100,\n", | ||
" \"// TODO\": \"Account for supporting the user choosing the anchor_loc and cov_around_anchor.\",\n", | ||
" \"// Current implementation\": \"the UE Tracks generator will not be using these values.\",\n", | ||
" \"// anchor_loc\": {},\n", | ||
" \"// cov_around_anchor\": {}\n", | ||
" }\n", | ||
" }\n", | ||
" }\n", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "d5d3f4fb", | ||
"metadata": {}, | ||
"source": [ | ||
"## Generate Data Set 1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "bf32a451", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data1 = get_ue_data(params)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0217fb7d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data1.head(10)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "0f112187", | ||
"metadata": {}, | ||
"source": [ | ||
"## Plot Dataset 1 " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "57d3c99b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"plot_ue_tracks(data1)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "507f5c0b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"velocity = preprocess_ue_data(data1)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "60b0bc3b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"velocity" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "3e4713fc", | ||
"metadata": {}, | ||
"source": [ | ||
"## Alpha Initialization" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ee3e00c1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"alpha0 = np.random.choice(np.arange(0, 1.1, 0.1))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "119f1534", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"print(\"Alpha0:\",alpha0)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "97a8c1ec", | ||
"metadata": {}, | ||
"source": [ | ||
"## Regress to Find Alpha 1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "12fdaf4b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"alpha1 = get_predicted_alpha(data1,alpha0,seed=42) # Adding seed for reproducibility" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "39eed46d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"alpha1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "1dc52c9d", | ||
"metadata": {}, | ||
"source": [ | ||
"## Generating new data using alpha 1\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "46d7e685", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#Changing alpha value to alpha1 in the params dictionary\n", | ||
"params['ue_tracks_generation']['params']['gauss_markov_params']['alpha'] = alpha1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ab4eb7cd", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"print(params['ue_tracks_generation']['params']['gauss_markov_params']['alpha'])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "3c700855", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data2 = get_ue_data(params)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "18a2b294", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "07a4c3aa", | ||
"metadata": {}, | ||
"source": [ | ||
"## Plot Dataset 2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "df4b1b11", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"plot_ue_tracks(data2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b727758e", | ||
"metadata": {}, | ||
"source": [ | ||
"## Regress to Find Alpha 2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5a268312", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"alpha2 = get_predicted_alpha(data1,alpha1,seed=42) # Adding seed for reproducibility" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "02575be1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"alpha2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "da3b378b", | ||
"metadata": {}, | ||
"source": [ | ||
"## Comparison Plot of Dataset 1 and Dataset2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0798532d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"plot_ue_tracks_side_by_side(data1, data2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "4c61c293", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.