blob: d85bd0b2964353ef4eff2d15fb5ca4e2d4fcbf4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/usr/bin/env python
""" """
__author__ = "Théo de la Hogue"
__credits__ = []
__copyright__ = "Copyright 2023, Ecole Nationale de l'Aviation Civile (ENAC)"
__license__ = "BSD"
from typing import TypeVar, Tuple, Any
from dataclasses import dataclass, field
import math
from argaze import GazeFeatures
import pandas
@dataclass
class AOIScanPathAnalyzer(GazeFeatures.AOIScanPathAnalyzer):
"""Implementation of transition matrix probabilities and density algorithm as described in ...
"""
def __post_init__(self):
pass
def analyze(self, aoi_scan_path: GazeFeatures.AOIScanPathType) -> Any:
"""Analyze aoi scan."""
assert(len(aoi_scan_path) > 1)
sequence = []
for aoi_scan_step in aoi_scan_path:
sequence.append(aoi_scan_step.aoi)
transition_matrix_probabilities = pandas.crosstab(pandas.Series(sequence[1:], name='to'), pandas.Series(sequence[:-1], name='from'), normalize=1)
transition_matrix_density = (transition_matrix_probabilities == 0.).astype(int).sum(axis=1).sum() / transition_matrix_probabilities.size
return transition_matrix_probabilities , transition_matrix_density
|