original_docstring: Computes 3-way ANOVA for Precision and factors - sequence, improvement, tracker
docstring: Computes 3-way ANOVA for Precision and factors - sequence, improvement, tracker
docstring_tokens: Computes 3 - way ANOVA for Precision and factors - sequence improvement tracker
code: def run3WayAnovaCenterError(self):
          """Computes 3-way ANOVA for Precision and factors - sequence, improvement, tracker"""
          g1 = []
          g2 = []
          g3 = []
          TRACKERS_SHORTCUTS = ["MIL","MFLOW","TLD","KCF","CSRT","ECO","ATOM","DSRPN","SiamDW","DiMP","KYS","Ocean"]
  
          for i in range(len(self.DATASET)):
              for j in range(len(self.IMPROVEMENTS)):
                  for k in range(len(TRACKERS_SHORTCUTS)):
                      g1.append(self.DATASET[i])
                      g2.append(self.IMPROVEMENTS[j])
                      g3.append(TRACKERS_SHORTCUTS[k])
  
          cerror = []
          for i in range(len(self.DATASET)):
              default_cerror_i = self._getCerrorAllTrackersSequence(seq_number=self.DATASET[i], default=True).tolist()
              border_cerror_i = self._getCerrorAllTrackersSequence(seq_number=self.DATASET[i], border=True).tolist()
              nfov_cerror_i = self._getCerrorAllTrackersSequence(seq_number=self.DATASET[i], nfov=True).tolist()
              # concat
              cerror = cerror + default_cerror_i + border_cerror_i + nfov_cerror_i
          
          cerror_rounded = [round(num / 100, 3) for num in cerror]
          # print(cerror_rounded)
  
          df = pd.DataFrame(list(zip(cerror_rounded, g1, g2, g3)), columns=['LocationError', 'sequence', 'improvement', 'tracker'], dtype=np.float64)
          print(df)
          
          # 3Way anova - https://www.pythonfordatascience.org/factorial-anova-python/
          model = ols("LocationError ~ C(sequence, Sum) + C(improvement, Sum) + C(tracker, Sum) + C(sequence, Sum):C(improvement, Sum) + C(sequence, Sum):C(tracker, Sum) + C(improvement, Sum):C(tracker, Sum)", data=df).fit()
          # model = ols("LocationError ~ C(sequence) + C(improvement) + C(tracker) + C(sequence):C(improvement) + C(sequence):C(tracker) + C(improvement):C(tracker)", data=df).fit()
          aov_table = sm.stats.anova_lm(model, typ=3)
          print(aov_table)
  
  
          matplotlib.rcParams.update({'font.size': 18})
          matplotlib.rcParams.update({'axes.labelsize': 18})
          
          # inspired and modified from https://www.reneshbedre.com/blog/anova.html
          # set custom color palette    
          colors = ["#ff6666", "#66ff66", "#0080ff"]
          sns.set_palette(sns.color_palette(colors))
          # create boxplot
          ax = sns.boxplot(x='tracker', y='LocationError', data=df, linewidth=2, hue="improvement")
          # ax = sns.catplot(x="tracker", y="auc", kind="swarm", data=df)
          plt.show()
code_tokens: def run3WayAnovaCenterError ( self ) : g1 = [ ] g2 = [ ] g3 = [ ] TRACKERS_SHORTCUTS = [ "MIL" , "MFLOW" , "TLD" , "KCF" , "CSRT" , "ECO" , "ATOM" , "DSRPN" , "SiamDW" , "DiMP" , "KYS" , "Ocean" ] for i in range ( len ( self . DATASET ) ) : for j in range ( len ( self . IMPROVEMENTS ) ) : for k in range ( len ( TRACKERS_SHORTCUTS ) ) : g1 . append ( self . DATASET [ i ] ) g2 . append ( self . IMPROVEMENTS [ j ] ) g3 . append ( TRACKERS_SHORTCUTS [ k ] ) cerror = [ ] for i in range ( len ( self . DATASET ) ) : default_cerror_i = self . _getCerrorAllTrackersSequence ( seq_number = self . DATASET [ i ] , default = True ) . tolist ( ) border_cerror_i = self . _getCerrorAllTrackersSequence ( seq_number = self . DATASET [ i ] , border = True ) . tolist ( ) nfov_cerror_i = self . _getCerrorAllTrackersSequence ( seq_number = self . DATASET [ i ] , nfov = True ) . tolist ( ) cerror = cerror + default_cerror_i + border_cerror_i + nfov_cerror_i cerror_rounded = [ round ( num / 100 , 3 ) for num in cerror ] df = pd . DataFrame ( list ( zip ( cerror_rounded , g1 , g2 , g3 ) ) , columns = [ 'LocationError' , 'sequence' , 'improvement' , 'tracker' ] , dtype = np . float64 ) print ( df ) model = ols ( "LocationError ~ C(sequence, Sum) + C(improvement, Sum) + C(tracker, Sum) + C(sequence, Sum):C(improvement, Sum) + C(sequence, Sum):C(tracker, Sum) + C(improvement, Sum):C(tracker, Sum)" , data = df ) . fit ( ) aov_table = sm . stats . anova_lm ( model , typ = 3 ) print ( aov_table ) matplotlib . rcParams . update ( { 'font.size' : 18 } ) matplotlib . rcParams . update ( { 'axes.labelsize' : 18 } ) colors = [ "#ff6666" , "#66ff66" , "#0080ff" ] sns . set_palette ( sns . color_palette ( colors ) ) ax = sns . boxplot ( x = 'tracker' , y = 'LocationError' , data = df , linewidth = 2 , hue = "improvement" ) plt . show ( )
short_docstring: Computes 3-way ANOVA for Precision and factors - sequence, improvement, tracker
short_docstring_tokens: Computes 3 - way ANOVA for Precision and factors - sequence improvement tracker
comment: """Computes 3-way ANOVA for Precision and factors - sequence, improvement, tracker"""$SEP$# concat$SEP$# print(cerror_rounded)$SEP$# 3Way anova - https://www.pythonfordatascience.org/factorial-anova-python/$SEP$# model = ols("LocationError ~ C(sequence) + C(improvement) + C(tracker) + C(sequence):C(improvement) + C(sequence):C(tracker) + C(improvement):C(tracker)", data=df).fit()$SEP$# inspired and modified from https://www.reneshbedre.com/blog/anova.html$SEP$# set custom color palette    $SEP$# create boxplot$SEP$# ax = sns.catplot(x="tracker", y="auc", kind="swarm", data=df)