diff options
author | Théo de la Hogue | 2023-05-24 10:53:38 +0200 |
---|---|---|
committer | Théo de la Hogue | 2023-05-24 10:53:38 +0200 |
commit | 8c7924b288d277823676b706d3a53fed4af8acc3 (patch) | |
tree | 54b24e60e7ef882c9ff2483c69da47eff7900dab /src | |
parent | 2fc1686f2d5587128730f564495794386bc57581 (diff) | |
download | argaze-8c7924b288d277823676b706d3a53fed4af8acc3.zip argaze-8c7924b288d277823676b706d3a53fed4af8acc3.tar.gz argaze-8c7924b288d277823676b706d3a53fed4af8acc3.tar.bz2 argaze-8c7924b288d277823676b706d3a53fed4af8acc3.tar.xz |
Improving stationary and transition entropy calculation.
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/GazeAnalysis/Entropy.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/argaze/GazeAnalysis/Entropy.py b/src/argaze/GazeAnalysis/Entropy.py index a185852..e6a60f1 100644 --- a/src/argaze/GazeAnalysis/Entropy.py +++ b/src/argaze/GazeAnalysis/Entropy.py @@ -24,32 +24,32 @@ class AOIScanPathAnalyzer(GazeFeatures.AOIScanPathAnalyzer): pass - def analyze(self, aoi_scan_path: GazeFeatures.AOIScanPathType, transition_matrix_probability: pandas.DataFrame) -> Any: + def analyze(self, aoi_scan_path: GazeFeatures.AOIScanPathType, transition_matrix_probabilities: pandas.DataFrame) -> Any: """Analyze aoi scan.""" assert(len(aoi_scan_path) > 1) # Count total number of fixations and how many fixations are there per aoi - scan_fixation_count, aoi_fixation_count = aoi_scan_path.fixation_count() + scan_fixations_count, aoi_fixations_count = aoi_scan_path.fixations_count() # Probability to have a fixation onto each aoi - stationary_probalities = {aoi: count/scan_fixation_count for aoi, count in aoi_fixation_count.items()} + stationary_probalities = {aoi: count/scan_fixations_count for aoi, count in aoi_fixations_count.items()} # Stationary entropy stationary_entropy = 0 for aoi, p in stationary_probalities.items(): - stationary_entropy += p * numpy.log(p + 0.00000001) + stationary_entropy += p * numpy.log(p + 1e-9) stationary_entropy *= -1 # Transition entropy transition_entropy = 0 - aoi_sum = transition_matrix_probability.apply(lambda row: row.apply(lambda p: p * numpy.log(p + 0.00000001)).sum(), axis=1) + destination_p_log_sum = transition_matrix_probabilities.apply(lambda row: row.apply(lambda p: p * numpy.log(p + 1e-9)).sum(), axis=1) - for aoi, s in aoi_sum.items(): + for aoi, s in destination_p_log_sum.items(): transition_entropy += s * stationary_probalities[aoi] |