Exemplo n.º 1
0
import manager
from knn_graph_clustering import Cluster

c = manager.Client(False)
b = c.load_basket_pickle('UrbanSound8K')
b2 = c.load_basket_pickle('ESC-50.pkl')

#cluster1 = Cluster(basket=b, k_nn=20)
#cluster1.run(feature='fusion')
#cluster1.plot()

cluster1 = Cluster(basket=b, k_nn=20)
scores_text = []
for k in [5, 6, 7, 8, 9, 10, 12, 14, 15, 20]:
    cluster1.run(feature='text', k_nn=k)
    scores_text.append(cluster1.scores)

scores_acoustic = []
for k in [5, 6, 7, 8, 9, 10, 12, 14, 15, 20]:
    cluster1.run(feature='acoustic', k_nn=k)
    scores_acoustic.append(cluster1.scores)

scores_fusion = []
for k in [5, 6, 7, 8, 9, 10, 12, 14, 15, 20]:
    cluster1.run(feature='fusion', k_nn=k)
    scores_fusion.append(cluster1.scores)

print scores_text
print scores_acoustic
print scores_fusion
import manager
from scipy.spatial.distance import pdist
from sklearn.metrics.pairwise import euclidean_distances
import webbrowser

c = manager.Client()
b = c.load_basket_pickle(
    'UrbanSound8K')  # Can load a basket from a search result instead

k_nn = 10  # param for k-nn graph creation

# __________________ FEATURE __________________ #
# Extract features and create similarity matrix from:
# Acoustic descriptors
b.analysis_stats = [None] * len(
    b
)  # this is because the basket is old and now analysis_stats contains None values initialy
b.add_analysis_stats()
b.remove_sounds_with_no_analysis()
d = b.extract_descriptor_stats(scale=True)
sound_similarity_matrix_d = euclidean_distances(d)
sound_similarity_matrix_d = sound_similarity_matrix_d / sound_similarity_matrix_d.max(
)
sound_similarity_matrix_d = 1 - sound_similarity_matrix_d

# Tags
t = b.preprocessing_tag()
for idx, tt in enumerate(t):
    b.sounds[idx].tags = tt
nlp = manager.Nlp(b)
nlp.create_sound_tag_matrix()
Exemplo n.º 3
0
 def __init__(self):
     self.c = manager.Client()
Exemplo n.º 4
0
 def __init__(self, query, descriptor):
     self.c = manager.Client()
     self.query = query
     self.descriptor_name = descriptor # TODO : A way to load several descriptor