Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
8365331
add_velocity function
PalkaPuri Aug 7, 2024
e2ee500
velocity predictor WIP
PalkaPuri Aug 8, 2024
6a19ae4
wip
PalkaPuri Aug 8, 2024
b5dde8a
format/lint
PalkaPuri Aug 8, 2024
a923457
specify forager column as int
PalkaPuri Aug 12, 2024
8cc4111
add warning
PalkaPuri Aug 12, 2024
892da93
format/lint
PalkaPuri Aug 12, 2024
f675d23
rename f,t for clarity
PalkaPuri Aug 13, 2024
1ee7caa
rerun notebook
PalkaPuri Aug 13, 2024
fcd34b2
add docstrings
PalkaPuri Aug 13, 2024
dc950c2
format/lint
PalkaPuri Aug 13, 2024
205235f
use inbuilt function for gaussian pdf
PalkaPuri Aug 13, 2024
b476a17
merge changes from pp-collab2-compute-velocity
PalkaPuri Aug 13, 2024
045e7d0
updated visualization
PalkaPuri Aug 13, 2024
05b3d90
add handling of nan values in visualization
PalkaPuri Aug 15, 2024
5774858
add _generate_pairwise_copying predictor
PalkaPuri Aug 15, 2024
41a7787
format/lint
PalkaPuri Aug 15, 2024
ab6ee7e
type hints
PalkaPuri Aug 15, 2024
47679f3
add pairwise predictor and animation function
PalkaPuri Aug 21, 2024
fac3f10
change velocity to backward looking
PalkaPuri Aug 21, 2024
ddf4572
Merge branch 'pp-collab2-compute-velocity' of https://github.com/Basi…
PalkaPuri Aug 21, 2024
4b242d8
docstrings and type hints
PalkaPuri Aug 21, 2024
82223c0
generate function and typehints
PalkaPuri Aug 21, 2024
11f5dce
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
PalkaPuri Aug 21, 2024
0dec71b
fixed naming, nan handling
PalkaPuri Aug 21, 2024
ea399b2
refactoring
PalkaPuri Aug 22, 2024
9a2ec97
vicsek wip
PalkaPuri Aug 23, 2024
033e565
update normalization of velocity predictors
PalkaPuri Aug 26, 2024
9c6854b
distance_to_next_move WIP
PalkaPuri Aug 26, 2024
8bfa2d0
Merge branch 'pp-collab2-vicsek-predictor' of https://github.com/Basi…
PalkaPuri Aug 26, 2024
e61915f
added alternates for distance_to_next_pos
PalkaPuri Aug 26, 2024
e79917e
lint/format
PalkaPuri Aug 26, 2024
ab7df53
updated nb example
PalkaPuri Aug 26, 2024
21e0361
update scores wip
PalkaPuri Aug 27, 2024
fca3235
merge rafal's changes
PalkaPuri Aug 27, 2024
d9cadcf
absolute paths for imports in modules
PalkaPuri Aug 27, 2024
3999139
update module to allow chnaging n
PalkaPuri Aug 27, 2024
540b11b
renaming
PalkaPuri Aug 27, 2024
a7b0495
format
PalkaPuri Aug 27, 2024
d0018bd
trace code in place
rfl-urbaniak Aug 27, 2024
319aa97
rename n
PalkaPuri Aug 28, 2024
cf3d543
merge staging-collab-2
PalkaPuri Aug 28, 2024
e47d161
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
PalkaPuri Aug 29, 2024
92a1957
add derive_predictors
PalkaPuri Aug 29, 2024
fd2a3f3
test inference wip
PalkaPuri Aug 29, 2024
d573538
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
PalkaPuri Aug 29, 2024
e2d3615
derive WIP
PalkaPuri Aug 29, 2024
f897604
test inference pipeline
PalkaPuri Aug 29, 2024
5230e77
format/lint
PalkaPuri Aug 29, 2024
e8dba19
format again
PalkaPuri Aug 29, 2024
a0f024c
one more format
PalkaPuri Aug 29, 2024
e07b3ff
lint
PalkaPuri Aug 29, 2024
5faaa13
format
PalkaPuri Aug 29, 2024
b01c8cf
adding doc to local_windows WIP
PalkaPuri Aug 29, 2024
e7bfeaf
small typos in docstrings
rfl-urbaniak Aug 30, 2024
4476c6b
added predictor time to logging
rfl-urbaniak Aug 30, 2024
bcbd8d6
added time to score logging
rfl-urbaniak Aug 30, 2024
72d28f4
time to logging, a few typos
rfl-urbaniak Aug 30, 2024
8d6a2ce
format lint
rfl-urbaniak Aug 30, 2024
5c70d1f
refactored proximity
rfl-urbaniak Aug 30, 2024
eb406a7
removed old proximity code
rfl-urbaniak Aug 30, 2024
bfbf187
format lint
rfl-urbaniak Aug 30, 2024
065518c
refactored trace
rfl-urbaniak Aug 30, 2024
20b89c1
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
rfl-urbaniak Aug 30, 2024
bdc5bff
added generate food to init
rfl-urbaniak Aug 30, 2024
0de9af7
format, lint
rfl-urbaniak Aug 30, 2024
1f0e506
update parameter names in docstring
PalkaPuri Sep 3, 2024
a7c55cc
explanation of score_kwargs
PalkaPuri Sep 3, 2024
b14029d
update next_step_score notebook
PalkaPuri Sep 3, 2024
2b8126f
update warning and add docstring to dataObject
PalkaPuri Sep 3, 2024
f00ce02
removing reusing velocity warning
PalkaPuri Sep 3, 2024
4d11e85
removed individual drop warning, add to derive_predictors_and_scores
PalkaPuri Sep 3, 2024
66688b8
lint/format
PalkaPuri Sep 3, 2024
c3f875e
fix bug in test
PalkaPuri Sep 3, 2024
d7fe531
format
PalkaPuri Sep 3, 2024
21083e8
Merge branch 'pp-collab2-derivepredictors' into pp-collab2-housekeeping
PalkaPuri Sep 3, 2024
2b8ecb2
local_windows update constraint implementation, add docstring
PalkaPuri Sep 3, 2024
5df34c7
rename variables
PalkaPuri Sep 3, 2024
62f0cb2
filter_by_distance update constraint implementation
PalkaPuri Sep 3, 2024
728a182
remove fps argument from subsampling func
PalkaPuri Sep 3, 2024
c7bc9bf
velocity- rename predictorID, update constraint implementation, docst…
PalkaPuri Sep 3, 2024
b583275
ensure all test notebooks run
PalkaPuri Sep 3, 2024
a621300
format/lint WIP
PalkaPuri Sep 3, 2024
e33c5f8
Merge branch 'ru-new-trace' into pp-collab2-housekeeping
PalkaPuri Sep 3, 2024
1b28cc3
ensure rafals nbs run
PalkaPuri Sep 3, 2024
c4ddd34
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
PalkaPuri Sep 4, 2024
2d9829e
type hints for kwargs in constraint func
PalkaPuri Sep 4, 2024
2ea9f12
add collab2 notebooks to automatic testing
PalkaPuri Sep 4, 2024
953558e
small fixes to local_windows.py docstrings
rfl-urbaniak Sep 4, 2024
f75ec48
interpunction in filtering.py
rfl-urbaniak Sep 4, 2024
d9249c1
proximity notebook now works
rfl-urbaniak Sep 5, 2024
575db78
wip
rfl-urbaniak Sep 5, 2024
2bd0546
fixed trace and derivation notebooks
rfl-urbaniak Sep 5, 2024
5913050
resolved type hinting problems
rfl-urbaniak Sep 5, 2024
f3f7e4f
fix some bugs
PalkaPuri Sep 5, 2024
bba492b
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
PalkaPuri Sep 5, 2024
dd1816c
notebook issue fix
PalkaPuri Sep 5, 2024
b4edb96
fix type hint in proximity
PalkaPuri Sep 5, 2024
ca693a8
Merge branch 'pp-collab2-housekeeping' of https://github.com/BasisRes…
rfl-urbaniak Sep 5, 2024
b88937e
grid_constraint_params updated to dict
PalkaPuri Sep 9, 2024
35f9131
interaction_constraint_params updated to dict
PalkaPuri Sep 9, 2024
1bcf668
make sure all notebooks pass + format/lint
PalkaPuri Sep 9, 2024
5572734
lint
rfl-urbaniak Sep 9, 2024
59e6215
lint
rfl-urbaniak Sep 9, 2024
f9b92da
lint
rfl-urbaniak Sep 9, 2024
bdd9965
lint
rfl-urbaniak Sep 9, 2024
1e1a548
lint
rfl-urbaniak Sep 9, 2024
5467b05
lint
rfl-urbaniak Sep 9, 2024
cc63147
lint
rfl-urbaniak Sep 9, 2024
c2f4c82
suspended old velocity test
rfl-urbaniak Sep 9, 2024
235fb07
changed DF merge to concat
PalkaPuri Sep 11, 2024
954d9e5
rhf old update
rfl-urbaniak Sep 17, 2024
032b3f4
Merge branch 'ru-random-hungry-2' of https://github.com/BasisResearch…
rfl-urbaniak Sep 17, 2024
944b20a
re-ran hungry and random foragers
rfl-urbaniak Sep 17, 2024
5780fef
following foragers replicated
rfl-urbaniak Sep 17, 2024
4ee8c47
format, lint
rfl-urbaniak Sep 18, 2024
1d31c6b
change to sublinear
rfl-urbaniak Sep 18, 2024
f0293fb
fixing velocity_predicts WIP
rfl-urbaniak Sep 18, 2024
e3d75c6
updated trace_predictor
rfl-urbaniak Sep 18, 2024
c1c0b8b
suspend animations in velocity predictors
rfl-urbaniak Sep 18, 2024
5205da4
added access predictor
rfl-urbaniak Sep 19, 2024
ec21ab4
updated random with access
rfl-urbaniak Sep 19, 2024
233c693
updateg hungry foragers
rfl-urbaniak Sep 19, 2024
bab23a2
updated followers with access
rfl-urbaniak Sep 19, 2024
b349262
format, lint
rfl-urbaniak Sep 19, 2024
9b6e058
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
rfl-urbaniak Sep 19, 2024
52b339b
fixed lint
rfl-urbaniak Sep 19, 2024
22104de
fixed imports in random foragers
rfl-urbaniak Sep 19, 2024
f20a472
fixing init
rfl-urbaniak Sep 19, 2024
605ed17
format, lint
rfl-urbaniak Sep 19, 2024
f3a6aa1
restored init fix
rfl-urbaniak Sep 19, 2024
8f61e4e
bump pyro to 1.9.1
rfl-urbaniak Sep 20, 2024
e0dfbaf
revert (chirho), remove deterministic from rendering
rfl-urbaniak Sep 20, 2024
1b204de
updated warning and added eCDF normalization
PalkaPuri Sep 25, 2024
52d0f14
Some polishing of the random/hungry/followers notebooks and fixing st…
dimkab Oct 2, 2024
2150069
format lint
rfl-urbaniak Oct 3, 2024
58f526c
Merge branch 'ru-random-hungry-2' of https://github.com/BasisResearch…
rfl-urbaniak Oct 3, 2024
63e3a87
Merge branch 'staging-collab-2' into pp-collab2-upgrade-derive
PalkaPuri Oct 6, 2024
7ef84c0
make copy of changes from collab2 folder
PalkaPuri Dec 12, 2024
89574fd
Merge remote-tracking branch 'origin/staging-velocity-prs' into pp-co…
PalkaPuri Dec 12, 2024
0aa4980
copied changes from collab2
PalkaPuri Dec 12, 2024
989aa5e
Merge branch 'main' of https://github.com/BasisResearch/collab-creatu…
rfl-urbaniak Dec 31, 2024
6e822da
small comments in derive_predictors, fix model graph
rfl-urbaniak Dec 31, 2024
391031c
fixing derive_pred notebook for testing
rfl-urbaniak Dec 31, 2024
667aa44
format, lint
rfl-urbaniak Dec 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions collab/foraging/toolkit/derive.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,23 @@ def _generate_combined_DF(

:param predictors_and_scoress: dictionary of computed predictors/scores
:param dropna: set to `True` to drop NaN elements from final DataFrame
:param add_scaled_values: set to `True` to scale the predictor/score columns and
:param add_scaled_values: set to `True` to scale the predictor/score columns using empirical CDF and
add the values as additional columns in final DataFrame
:return: final, flattened DataFrame containing all computed predictors as columns
"""
list_DFs = [_generate_DF_from_nestedList(p) for p in predictors_and_scores.values()]
combinedDF = list_DFs[0]

for i in range(1, len(list_DFs)):
combinedDF = combinedDF.merge(list_DFs[i], how="inner")
dict_DFs = {
key: _generate_DF_from_nestedList(predictors_and_scores[key])
for key in predictors_and_scores.keys()
}
combinedDF = pd.concat(
[dict_DFs[key][[key]] for key in dict_DFs.keys()], axis=1
) # only combining predictor/score columns on index

# list_DFs = [_generate_DF_from_nestedList(p) for p in predictors_and_scores.values()]
# combinedDF = list_DFs[0]
# for i in range(1, len(list_DFs)):
# combinedDF = combinedDF.merge(list_DFs[i], how="inner")

if dropna:
og_frames = len(combinedDF)
Expand All @@ -55,21 +63,17 @@ def _generate_combined_DF(
if dropped_frames:
warnings.warn(
f"""
Dropped {dropped_frames}/{og_frames} frames from `derivedDF` due to NaN values.
Missing values can arise when computations depend on next/previous step positions
that are unavailable. See documentation of the corresponding predictor/score generating
functions for more information.
Dropped {dropped_frames}/{og_frames} (~{100*dropped_frames/og_frames:.2f}%) rows from `derivedDF`
due to NaN values. Missing values can arise when computations depend on next/previous positions
that are unavailable. See documentation of the corresponding predictor/score generating functions
for more information.
"""
)

# scale predictor columns
if add_scaled_values:
for key in predictors_and_scores.keys():
column_min = combinedDF[key].min()
column_max = combinedDF[key].max()
combinedDF[f"{key}_scaled"] = (combinedDF[key] - column_min) / (
column_max - column_min
)
combinedDF[f"{key}_scaled"] = combinedDF[key].rank(method="dense", pct=True)

return combinedDF

Expand Down Expand Up @@ -106,8 +110,8 @@ def derive_predictors_and_scores(
"nextStep_squared" : {"nonlinearity_exponent" : 2},
}
:param dropna: set to `True` to drop NaN elements from the final DataFrame
:param add_scaled_values: set to `True` to compute scaled predictor scores
and add them as additional columns in final DataFrame
:param add_scaled_values: set to `True` to compute scaled predictors/scores using empirical
CDF and add them as additional columns in final DataFrame
:return: final, flattened DataFrame containing all computed predictors as columns
"""

Expand All @@ -117,9 +121,11 @@ def derive_predictors_and_scores(
foragers_object.score_kwargs = score_kwargs

# generate local_windows and add to object
start = time.time()
local_windows = generate_local_windows(foragers_object)
foragers_object.local_windows = local_windows

end = time.time()
derivation_logger.info(f"Local windows completed in {end-start:.2f} seconds.")
derived_quantities = {}

# calculate predictors
Expand Down Expand Up @@ -150,8 +156,10 @@ def derive_predictors_and_scores(
foragers_object.derived_quantities = derived_quantities

# generate combined DF
start = time.time()
derivedDF = _generate_combined_DF(derived_quantities, dropna, add_scaled_values)

end = time.time()
derivation_logger.info(f"derivedDF generated in {end-start:.2f} seconds.")
# save to object
foragers_object.derivedDF = derivedDF

Expand Down
Loading
Loading