Ejemplo n.º 1
0
 def test_case_5(self):
     song = song_list[5]['song']
     true_genre = song.genre
     run_all(rule_list=self.rules,
             defined_variables=SongVariables(song),
             defined_actions=SongActions(song),
             stop_on_first_trigger=False)
Ejemplo n.º 2
0
 def test_case_26_to_50(self):
     for i in range(26, 50):
         song = song_list[i]['song']
         true_genre = song.genre
         run_all(rule_list=self.rules,
                 defined_variables=SongVariables(song),
                 defined_actions=SongActions(song),
                 stop_on_first_trigger=False)
Ejemplo n.º 3
0
 def confusion_matrix(self):
     df = DataFrame(index=range(0, 50), columns=['true', 'predict'])
     for i in range(0, 50):
         song = song_list[i]['song']
         true_genre = str(song.genre)
         run_all(rule_list=self.rules,
                 defined_variables=SongVariables(song),
                 defined_actions=SongActions(song),
                 stop_on_first_trigger=False)
         df.loc[i] = [true_genre, song.genre]
     cnf_matrix = ConfusionMatrix(df['true'], df['predict'])
     cnf_matrix.plot()
     plt.show()
Ejemplo n.º 4
0
 def test_accuracy(self):
     total = 50
     correct = 0
     df = DataFrame(index=range(0, 50), columns=['true', 'predict'])
     for i in range(0, 50):
         song = song_list[i]['song']
         true_genre = song.genre
         run_all(rule_list=self.rules,
                 defined_variables=SongVariables(song),
                 defined_actions=SongActions(song),
                 stop_on_first_trigger=False)
         df.loc[i] = [true_genre, song.genre]
         if true_genre == song.genre:
             correct += 1
     print(correct / total)
     cnf_matrix = ConfusionMatrix(df['true'], df['predict'])
     cnf_matrix.plot()
     plt.show()
     self.assertGreater((correct / total), 0.5)