algo/IBDT.py
def train(self, gaze:list) -> None:
        """Perform training on the data specified, split velocity means on 2 clusters and update model hyperparameters.

        :param gaze: list of IBDT_Data to train on.
        :return:
        """
        samples = deque()



        #Find first valid sample
        for index in range(0, len(gaze)):
            previous = gaze[index]
            if (previous != gaze[len(gaze)-1]) and (previous.base.confidence < self.minSampleConfidence):
                previous.base.v = np.nan
                continue
            else:
                break


        #Estimate velocities for remaining training samples
        #TODO refactor to apply() on dataframe
        for index2 in range(index+1, len(gaze)):
            g = gaze[index2]
            #not fully applicable to SMI data
            if g.base.confidence < self.minSampleConfidence:
                g.base.v = np.nan
                continue


            g.base.v = self.estimateVelocity( g, previous )
            if not np.isnan(g.base.v):
                samples.append(g.base.v)

            previous = g




        self.model = cv2.ml.EM_create()
        self.model.setClustersNumber(2)
        self.model.setCovarianceMatrixType(cv2.ml.EM_COV_MAT_GENERIC)
        #TODO + or binary OR??
        self.model.setTermCriteria((cv2.TERM_CRITERIA_COUNT + cv2.TERM_CRITERIA_EPS, 15000, 1e-6))
        self.model.trainEM(np.array(samples))



        self.fIdx = 0
        self.sIdx = 1
        means = self.model.getMeans()
        #higher mean velocities are saccades
        if means[0] > means[1]:
            self.fIdx = 1
            self.sIdx = 0

        self.fMean = means[self.fIdx]
        self.sMean = means[self.sIdx]
Perform training on the data specified, split velocity means on 2 clusters and update model hyperparameters.

        :param gaze: list of IBDT_Data to train on.
        :return:
        
Perform training on the data specified, split velocity means on 2 clusters and update model hyperparameters.
Perform training on the data specified split velocity means on 2 clusters and update model hyperparameters .
def train(self, gaze:list) -> None:
        samples = deque()
        for index in range(0, len(gaze)):
            previous = gaze[index]
            if (previous != gaze[len(gaze)-1]) and (previous.base.confidence < self.minSampleConfidence):
                previous.base.v = np.nan
                continue
            else:
                break
        for index2 in range(index+1, len(gaze)):
            g = gaze[index2]
            if g.base.confidence < self.minSampleConfidence:
                g.base.v = np.nan
                continue
            g.base.v = self.estimateVelocity( g, previous )
            if not np.isnan(g.base.v):
                samples.append(g.base.v)
            previous = g
        self.model = cv2.ml.EM_create()
        self.model.setClustersNumber(2)
        self.model.setCovarianceMatrixType(cv2.ml.EM_COV_MAT_GENERIC)
        self.model.setTermCriteria((cv2.TERM_CRITERIA_COUNT + cv2.TERM_CRITERIA_EPS, 15000, 1e-6))
        self.model.trainEM(np.array(samples))
        self.fIdx = 0
        self.sIdx = 1
        means = self.model.getMeans()
        if means[0] > means[1]:
            self.fIdx = 1
            self.sIdx = 0
        self.fMean = means[self.fIdx]
        self.sMean = means[self.sIdx]
def train ( self , gaze : list ) -> None : samples = deque ( ) for index in range ( 0 , len ( gaze ) ) : previous = gaze [ index ] if ( previous != gaze [ len ( gaze ) - 1 ] ) and ( previous . base . confidence < self . minSampleConfidence ) : previous . base . v = np . nan continue else : break for index2 in range ( index + 1 , len ( gaze ) ) : g = gaze [ index2 ] if g . base . confidence < self . minSampleConfidence : g . base . v = np . nan continue g . base . v = self . estimateVelocity ( g , previous ) if not np . isnan ( g . base . v ) : samples . append ( g . base . v ) previous = g self . model = cv2 . ml . EM_create ( ) self . model . setClustersNumber ( 2 ) self . model . setCovarianceMatrixType ( cv2 . ml . EM_COV_MAT_GENERIC ) self . model . setTermCriteria ( ( cv2 . TERM_CRITERIA_COUNT + cv2 . TERM_CRITERIA_EPS , 15000 , 1e-6 ) ) self . model . trainEM ( np . array ( samples ) ) self . fIdx = 0 self . sIdx = 1 means = self . model . getMeans ( ) if means [ 0 ] > means [ 1 ] : self . fIdx = 1 self . sIdx = 0 self . fMean = means [ self . fIdx ] self . sMean = means [ self . sIdx ]
Perform training on the data specified, split velocity means on 2 clusters and update model hyperparameters.
Perform training on the data specified split velocity means on 2 clusters and update model hyperparameters .
"""Perform training on the data specified, split velocity means on 2 clusters and update model hyperparameters.

        :param gaze: list of IBDT_Data to train on.
        :return:
        """ #Find first valid sample #Estimate velocities for remaining training samples #TODO refactor to apply() on dataframe #not fully applicable to SMI data #TODO + or binary OR?? #higher mean velocities are saccades
None
self
gaze
list
list of IBDT_Data to train on.
list of IBDT_Data to train on .