Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Baseline Similarity Evaluation with Annoy #364

Open
wants to merge 228 commits into
base: master
from
Open
Changes from all commits
Commits
Show all changes
228 commits
Select commit Hold shift + click to select a range
35e8549
Disabled unnecessary docker containers, started implementing similari…
philtgun May 14, 2018
2aab125
Added db dump, implemented mfcc into db
philtgun May 16, 2018
a2651b8
Added db API for similarity
philtgun May 17, 2018
e89f14c
Implemented template that shows similar recordings
philtgun May 18, 2018
d2e125a
Implemented data population and view, 2 metrics: key, bpm; and their …
philtgun May 28, 2018
d8da8d3
Adding more metrics
philtgun May 29, 2018
5c37b27
WIP: make metrics easily addable/removable
philtgun Jun 14, 2018
1d2f985
Refactored similarity metrics to be dynamicly added to db
philtgun Jun 15, 2018
ab71976
Added init command for similarity
philtgun Jun 18, 2018
e2b22e1
Finished workflow for adding metrics (new and hybrid), now supporting…
philtgun Jun 19, 2018
f250ad3
Fixed moods descriptor
philtgun Jun 20, 2018
f5a8d2b
Optimized query to get unprocessed rows for similarity
philtgun Jun 21, 2018
4e120e9
Added remove_similarity command
philtgun Jun 22, 2018
8c74498
Removed transaction from add_similarity, added some guards
philtgun Jun 22, 2018
0527083
Add experimental pl/pgsql metric computation
philtgun Jun 22, 2018
47d6fe5
Optimized adding of metrics
philtgun Jun 26, 2018
5eda235
Make stat computation sampled, show progress
philtgun Jun 26, 2018
b0235d2
Fixed non-working removal of mbid duplicates
philtgun Jun 27, 2018
16f9516
Added onsetrate, labels for future metrics
philtgun Jun 28, 2018
494c7f3
WIP: creating similarity class hierarchy
philtgun Jul 6, 2018
8e0ac8d
WIP: created class structures, migrating code
philtgun Jul 11, 2018
d1324aa
Finished refactoring
philtgun Jul 13, 2018
4373ad3
Added NaN arrays suport for highlevel metrics
philtgun Jul 17, 2018
0b36e5a
Add db stuctures for evaluation
philtgun Jul 17, 2018
866714e
Added db table for metrics
philtgun Jul 20, 2018
0e40b71
Added rating api and buttons to rate similarity
philtgun Jul 23, 2018
05b0905
Finished evaluation implementation
philtgun Jul 24, 2018
b3dc6a6
Fixed a bug related to adding existing similarity
philtgun Jul 24, 2018
77a305d
Updated metric descriptions and rendering
philtgun Jul 24, 2018
cbb1466
Fixed wrong order of operations on creating metric
philtgun Jul 24, 2018
81f667e
Fixed bug with hybrid metric column concatanation
philtgun Jul 25, 2018
4f0dd68
Added script to prehit test endpoints
philtgun Aug 8, 2018
8a5ca65
Merge remote-tracking branch 'philtgun/master' into compute-metrics
aidanlw17 Jun 19, 2019
8203af8
Remove postgres cube indexing
aidanlw17 Jun 19, 2019
7474b4d
Add similarity_metrics to create_tables, add foreign keys and primary…
aidanlw17 Jun 19, 2019
5b666e9
Renaming
aidanlw17 Jun 19, 2019
91ef2f2
Modify get_similar_recordings with postgres to use submission offset
aidanlw17 Jun 19, 2019
caca143
Removes unnecessary files
aidanlw17 Jun 19, 2019
12b3ea5
Removes unnecessary webserver files for similarity eval
aidanlw17 Jun 19, 2019
eddc26a
Refactor queries with sqlalchemy.text and query params
aidanlw17 Jun 19, 2019
8df812e
Removes unnecessary function
aidanlw17 Jun 19, 2019
bce247d
Drop similarity tables when resetting db for testing
aidanlw17 Jun 19, 2019
a2c30e6
Alter create table for similarity
aidanlw17 Jun 26, 2019
fb07084
Resume alphabetical ordering of dependencies
aidanlw17 Jun 30, 2019
9db618e
Refactor sql for dropping tables and types
aidanlw17 Jun 30, 2019
4d5514f
Add_metrics function to add all metrics simultaneously
aidanlw17 Jun 30, 2019
967522b
Remove unnecessary whitespace
aidanlw17 Jun 30, 2019
c0eeef6
Refactor metrics classes to use queries from db module
aidanlw17 Jun 30, 2019
4f0e1e0
Add tests for db.data
aidanlw17 Jun 30, 2019
69cf175
Add highlevel models response for db tests
aidanlw17 Jun 30, 2019
532811d
Reformatting
aidanlw17 Jun 30, 2019
4db13df
Add tests for similarity methods in db module
aidanlw17 Jun 30, 2019
31b9eba
Remove queries from cli commands, add command for computing all metrics
aidanlw17 Jun 30, 2019
4a18a80
Remove function call in WIP update_metric cli
aidanlw17 Jun 30, 2019
4dff3da
Fix error in drop tables
aidanlw17 Jul 3, 2019
e4e1731
Adds methods for getting required similarity data in db module
aidanlw17 Jul 3, 2019
39f6a88
Add a check for submission
aidanlw17 Jul 3, 2019
5b36845
Adds a highlevel json file for test_mbid
aidanlw17 Jul 3, 2019
a730f0a
Fixes bug with normalizing metric when stddev is 0
aidanlw17 Jul 3, 2019
9209c85
Improves and fixes bugs in unittests
aidanlw17 Jul 3, 2019
ed67833
remove comments
aidanlw17 Jul 3, 2019
8b99e16
remove comments
aidanlw17 Jul 3, 2019
6e65dcf
Refactor to use submit_similarity_by_id in the bulk add
aidanlw17 Jul 9, 2019
c02a9e9
Add method to create a list of metric classes, initialized
aidanlw17 Jul 9, 2019
adc89ae
Remove unnecessary attribute in metrics, add check for empty stats
aidanlw17 Jul 9, 2019
5f65492
Merge remote-tracking branch 'origin' into compute-metrics
aidanlw17 Jul 9, 2019
0fe3d75
Merge remote-tracking branch 'upstream/master' into compute-metrics
aidanlw17 Jul 9, 2019
ca44ade
Add function to check for lowlevel submission
aidanlw17 Jul 9, 2019
1190687
Add tests for submit_similarity_by_id
aidanlw17 Jul 9, 2019
dfb2d7d
Refactoring, docstrings, and adding function to initialize metrics
aidanlw17 Jul 9, 2019
a39b05f
Use params instead of string interpolation
aidanlw17 Jul 10, 2019
5bdf613
Fixes string interpolation bug when deleting metrics
aidanlw17 Jul 10, 2019
fddf0e5
Remove uses of create/delete metrics and metric class
aidanlw17 Jul 10, 2019
c0c3a0d
Remove functions to add/delete metrics and metric metadata
aidanlw17 Jul 10, 2019
9995fa5
Add sql to populate similarity_metrics table on creation
aidanlw17 Jul 10, 2019
afb5712
Execute inserts for similarity_metrics when db is initialized
aidanlw17 Jul 10, 2019
8b8dbae
Add sql statements to create/delete new metrics
aidanlw17 Jul 10, 2019
5e89a00
Remove unnecessary argument
aidanlw17 Jul 10, 2019
56657fe
Similarity stats unit tests and fixing index error
aidanlw17 Jul 11, 2019
130f8e3
Removes comment
aidanlw17 Jul 11, 2019
bc6901f
Rename script to populate metrics table
aidanlw17 Jul 18, 2019
abdd9bc
Removes unnecessary file for creating and deleting metrics
aidanlw17 Jul 18, 2019
5521c2d
Removes string interpolation from insert query
aidanlw17 Jul 18, 2019
0560b1c
Renaming and refactoring stats files
aidanlw17 Jul 18, 2019
19f414f
Update submission tests
aidanlw17 Jul 18, 2019
a886fbf
Add empty line
aidanlw17 Jul 22, 2019
bac88a1
Improve documentation and fix default batch size
aidanlw17 Jul 22, 2019
1c232d3
Add function to extract features for metrics
aidanlw17 Jul 22, 2019
ed23c3a
Improve query methods and Adapt submission function to accept data as…
aidanlw17 Jul 22, 2019
19e7c32
Add support for single recording submission
aidanlw17 Jul 22, 2019
e3ac8c4
Remove constant
aidanlw17 Jul 22, 2019
1a92bed
Change method for selecting features from data
aidanlw17 Jul 23, 2019
b6bd53a
Adds similarity schema
aidanlw17 Jul 23, 2019
34cd5bb
Fix references to similarity tables
aidanlw17 Jul 23, 2019
47d2f4f
Remove unnecessary import
aidanlw17 Jul 23, 2019
188ca6e
Update tests and add two checks for data
aidanlw17 Jul 23, 2019
4965d6b
Adds documentation for similarity submission
aidanlw17 Jul 23, 2019
d53e83e
Test for getting similarity by id and fix exception
aidanlw17 Jul 23, 2019
33ef083
Remove unnecessary whitespace
aidanlw17 Jul 23, 2019
490d422
Fix tests for submitting similarity by id
aidanlw17 Jul 24, 2019
b371b93
Fix vector transformation for empty highlevel model
aidanlw17 Jul 24, 2019
8e239ac
Remove unnecessary check for data
aidanlw17 Jul 24, 2019
cf4efda
Adapt adding metrics to new similarity stats methods
aidanlw17 Aug 13, 2019
50734a3
Remove unneeded method
aidanlw17 Aug 13, 2019
ecb529f
Remove unneeded call to compute stats
aidanlw17 Aug 13, 2019
b61b609
Computes stats using numpy
aidanlw17 Aug 13, 2019
34dadf6
Adds init command for similarity, and compute-stats command
aidanlw17 Aug 13, 2019
ef7ee13
Fix failing tests that need computed stats
aidanlw17 Aug 13, 2019
6e9f118
Adds documentation on similarity_stats
aidanlw17 Aug 13, 2019
6f8309f
Alter metrics to hold hl model names, fix bug in query for models
aidanlw17 Aug 15, 2019
4d5076b
Only add active models and add docstring
aidanlw17 Aug 15, 2019
39d84fa
Add only active hl models, add logger, and fix row fetching
aidanlw17 Aug 15, 2019
7f19f99
Alter model naming
aidanlw17 Aug 24, 2019
2718ffa
Adds function to get data batch and corrects batch query
aidanlw17 Aug 24, 2019
008e3f2
Add tests for add_metrics and get_batch_data
aidanlw17 Aug 24, 2019
77d63c5
Remove line break on string
aidanlw17 Aug 24, 2019
a2bb237
Adds test data for add_metrics
aidanlw17 Aug 24, 2019
79139b0
Remove timing of add_metrics
aidanlw17 Aug 24, 2019
7cb77d9
Add annoy as a dependency
aidanlw17 Jun 24, 2019
68336b7
Creates index_model class and init function
aidanlw17 Jun 24, 2019
a303485
Adds exceptions for similarity module and get_vector_dimension
aidanlw17 Jun 24, 2019
97957b2
Add build/save/load functionality
aidanlw17 Jun 24, 2019
429b297
Adds functions to add items to index
aidanlw17 Jun 24, 2019
5ffcce6
Add script for building a single index
aidanlw17 Jun 25, 2019
c04088d
Add functionality to query by mbid or by id
aidanlw17 Jun 25, 2019
c910835
Adds scripts to query annoy and postgres for similar recordings
aidanlw17 Jun 25, 2019
6b960c9
Parse parameters to index to check that they are possible
aidanlw17 Jun 25, 2019
4d17a43
Parse parameters to index to check that they are possible
aidanlw17 Jun 25, 2019
d28d9c1
Adds endpoint for similar recordings to a single (MBID, offset) combi…
aidanlw17 Jun 25, 2019
aa60e8d
Adds bulk endpoint for similar recordings
aidanlw17 Jun 25, 2019
d799388
Adds bulk endpoint for similar recordings
aidanlw17 Jun 25, 2019
acf5da9
Add bulk get functionality to index model
aidanlw17 Jun 25, 2019
bf56107
Add bulk get functionality to index model
aidanlw17 Jun 25, 2019
138c23e
removes postgres and hybrid similarity
aidanlw17 Jul 4, 2019
9dfd2d0
Add blueprint for similarity api
aidanlw17 Jul 4, 2019
cede717
Add endpoint to get distance between recordings
aidanlw17 Jul 4, 2019
cb8ff21
Remove whitespace
aidanlw17 Jul 4, 2019
378640d
Alters parameter checking for similarity indices
aidanlw17 Jul 6, 2019
faef716
Alters exception for getting lowlevel id
aidanlw17 Jul 6, 2019
031e470
Add unit testing for get_similar_recordings
aidanlw17 Jul 6, 2019
a38030b
Adds tests for bulk similarity lookup
aidanlw17 Jul 6, 2019
c08cea5
Uppercase MBID in docstring
aidanlw17 Jul 6, 2019
41aa4b9
Remove connection property for AnnoyModel class
aidanlw17 Jul 7, 2019
ec2ad4b
Uses mock AnnoyModel to test similarity lookup endpoints
aidanlw17 Jul 7, 2019
8f4db80
Fix typo in bulk get
aidanlw17 Jul 7, 2019
402d863
Fix issue with loading index function call
aidanlw17 Jul 7, 2019
e50031a
Add test cases for similarity between recordings
aidanlw17 Jul 7, 2019
15004a9
Fix error in similarity between return value
aidanlw17 Jul 7, 2019
afa6390
Refactor to move sql queries into db module
aidanlw17 Jul 7, 2019
ed01882
Remove unneeded imports in similarity/script.py
aidanlw17 Jul 8, 2019
910e741
Adds utilities for querying
aidanlw17 Jun 25, 2019
26882a8
Parse parameters to index to check that they are possible
aidanlw17 Jun 25, 2019
350bb90
Add cli command for removing index
aidanlw17 Jun 25, 2019
61a0f56
Adds bulk endpoint for similar recordings
aidanlw17 Jun 25, 2019
cae3f78
Adds bulk endpoint for similar recordings
aidanlw17 Jun 25, 2019
7373665
Add bulk get functionality to index model
aidanlw17 Jun 25, 2019
d5a1ede
Add bulk get functionality to index model
aidanlw17 Jun 25, 2019
87573d3
removes postgres and hybrid similarity
aidanlw17 Jul 4, 2019
643bedf
Add endpoint to get distance between recordings
aidanlw17 Jul 4, 2019
ec1d205
Alters parameter checking for similarity indices
aidanlw17 Jul 6, 2019
4485248
Adds tests for bulk similarity lookup
aidanlw17 Jul 6, 2019
7e1de16
Remove connection property for AnnoyModel class
aidanlw17 Jul 7, 2019
29d399a
Uses mock AnnoyModel to test similarity lookup endpoints
aidanlw17 Jul 7, 2019
2b47a1c
Fix issue with loading index function call
aidanlw17 Jul 7, 2019
826bae3
Add test cases for similarity between recordings
aidanlw17 Jul 7, 2019
4fe0425
Refactor to move sql queries into db module
aidanlw17 Jul 7, 2019
08f9bd2
Adds and improves docstrings
aidanlw17 Jul 8, 2019
9d8be5c
Adds and improves docstrings
aidanlw17 Jul 8, 2019
bf05247
Remove duplicate function after rebase
aidanlw17 Jul 10, 2019
ab1613f
Fix n_neighbours parsing
aidanlw17 Jul 10, 2019
37996de
Add unit tests and refactor
aidanlw17 Jul 11, 2019
d751d85
Fix bug in unit test
aidanlw17 Jul 12, 2019
d9eced5
Refactors to avoid circular imports and remove unnecessary function
aidanlw17 Jul 12, 2019
df6cb6f
Small bug fix and changes to unit test mocks
aidanlw17 Jul 16, 2019
8d88e5d
Change exception for python2
aidanlw17 Jul 16, 2019
c419188
Add tests for build/save/load cycle and init in index model
aidanlw17 Jul 16, 2019
158819d
Finishes test suite for index_model
aidanlw17 Jul 17, 2019
5824879
Adds similarity eval table and fks in update
aidanlw17 Jul 17, 2019
67d9c36
Drop similarity_eval table and fks in script
aidanlw17 Jul 17, 2019
7bc1174
Add route and template for similarity metrics
aidanlw17 Jul 17, 2019
4987b66
Remove check for visible metrics
aidanlw17 Jul 17, 2019
0ea89a2
adds schema, templates, and routes
aidanlw17 Jul 18, 2019
86e7a65
Adds similarity schema
aidanlw17 Jul 23, 2019
a143b58
Fix references to similarity tables
aidanlw17 Jul 23, 2019
e2f06c0
Add support for similarity schema
aidanlw17 Jul 26, 2019
5f0e59b
Improve appearance of similar recordings link
aidanlw17 Jul 26, 2019
bf35250
Fix typo
aidanlw17 Jul 26, 2019
e2de451
Upgrade annoy to 1.16.0
aidanlw17 Jul 28, 2019
0ef2bda
Improve speed of adding indices and remove default for params
aidanlw17 Jul 28, 2019
f49bf1c
Add utility to initialize indices
aidanlw17 Jul 28, 2019
f9c1af0
Add message for error
aidanlw17 Jul 31, 2019
041e4c9
Adds forms for evaluation
aidanlw17 Jul 31, 2019
04a1fd2
Adds script for similarity eval submission
aidanlw17 Jul 31, 2019
337ef28
Alter evaluation to adhere to schema and forms
aidanlw17 Jul 31, 2019
397c5d0
Add utility for offset
aidanlw17 Jul 31, 2019
f99adae
Build route functions for displaying and submitting eval
aidanlw17 Jul 31, 2019
5bbba9e
Remove unnecessary table
aidanlw17 Aug 1, 2019
eeaa26d
Populate similarity.eval_params table
aidanlw17 Aug 1, 2019
b7c3dd5
Naming changes and unique constraints
aidanlw17 Aug 1, 2019
665c4c1
Add evaluation and submit eval results functions
aidanlw17 Aug 1, 2019
8d7f1e5
Alter index model get_nns query to return distances
aidanlw17 Aug 1, 2019
61c2cb6
Alter eval view functions to collect submission info
aidanlw17 Aug 1, 2019
5b26028
Update sql scripts with eval update
aidanlw17 Aug 2, 2019
40defe8
Fix similarity schema references
aidanlw17 Aug 2, 2019
a8c618d
Fix typo in test
aidanlw17 Aug 2, 2019
3d6ba81
Refactor utils to avoid circular imports
aidanlw17 Aug 2, 2019
19c2297
Fix exceptions in api endpoint
aidanlw17 Aug 2, 2019
1abad44
Fix process batch size and conflicts for submitting eval_results
aidanlw17 Aug 9, 2019
1df3efc
Alter get_nns functions to support eval_results
aidanlw17 Aug 9, 2019
49500ba
Remove use of time library
aidanlw17 Aug 9, 2019
645682a
Update similarity api to match get_nns changes
aidanlw17 Aug 9, 2019
1d1bab4
get_similar submits correct info about eval
aidanlw17 Aug 9, 2019
4e8fd37
Refactor for similarity ui blueprint
aidanlw17 Aug 9, 2019
0b5aa75
Add constraint on eval feedback - one form per user
aidanlw17 Aug 22, 2019
86983f9
Alter get_mbids_by_ids to preserve order
aidanlw17 Aug 22, 2019
697e00c
Add function to check for user in eval submissions
aidanlw17 Aug 22, 2019
dcb1fb2
Add offset validation utility
aidanlw17 Aug 22, 2019
d8c75b9
Adds evaluation and metrics templates
aidanlw17 Aug 22, 2019
77285e7
Add evaluation with react
aidanlw17 Aug 22, 2019
f48315d
Add similarity eval routes
aidanlw17 Aug 22, 2019
43ff38e
Remove unneeded comments
aidanlw17 Aug 24, 2019
1205d38
Compute stats before submitting similarity
aidanlw17 Aug 24, 2019
305ea09
Catching error displays error message
aidanlw17 Aug 26, 2019
378e04d
Adds patch for musicbrainz
aidanlw17 Aug 26, 2019
6b54bf4
Removes unneeded comment
aidanlw17 Aug 26, 2019
50b030a
Add add-indices to init command and reorganize command options
aidanlw17 Aug 27, 2019
9a75b6e
Use logger instead of print
aidanlw17 Aug 27, 2019
3774a29
Edits docstring
aidanlw17 Aug 27, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -38,3 +38,7 @@ export
/files
ve
*.swp

cache_namespaces
package-lock.json

@@ -115,4 +115,39 @@ ALTER TABLE feedback
FOREIGN KEY (user_id)
REFERENCES "user" (id);

ALTER TABLE similarity.similarity
ADD CONSTRAINT similarity_fk_lowlevel
FOREIGN KEY (id)
REFERENCES lowlevel (id);

ALTER TABLE similarity.similarity_stats
ADD CONSTRAINT similarity_stats_fk_metric
FOREIGN KEY (metric)
REFERENCES similarity.similarity_metrics (metric);

ALTER TABLE similarity.eval_params
ADD CONSTRAINT eval_params_fk_metric
FOREIGN KEY (metric)
REFERENCES similarity.similarity_metrics (metric);

ALTER TABLE similarity.eval_results
ADD CONSTRAINT eval_results_fk_lowlevel
FOREIGN KEY (query_id)
REFERENCES lowlevel (id);

ALTER TABLE similarity.eval_results
ADD CONSTRAINT eval_results_fk_eval_params
FOREIGN KEY (params)
REFERENCES similarity.eval_params (id);

ALTER TABLE similarity.eval_feedback
ADD CONSTRAINT eval_feedback_fk_user
FOREIGN KEY (user_id)
REFERENCES "user" (id);

ALTER TABLE similarity.eval_feedback
ADD CONSTRAINT eval_feedback_fk_query_id
FOREIGN KEY (eval_id)
REFERENCES similarity.eval_results (id);

COMMIT;
@@ -20,5 +20,10 @@ ALTER TABLE challenge ADD CONSTRAINT challenge_pkey PRIMARY KEY (id);
ALTER TABLE dataset_eval_challenge ADD CONSTRAINT dataset_eval_challenge_pkey PRIMARY KEY (dataset_eval_job, challenge_id);
ALTER TABLE api_key ADD CONSTRAINT api_key_pkey PRIMARY KEY (value);
ALTER TABLE feedback ADD CONSTRAINT feedback_pkey PRIMARY KEY (user_id, highlevel_model_id);
ALTER TABLE similarity.similarity ADD CONSTRAINT similarity_pkey PRIMARY KEY (id);
ALTER TABLE similarity.similarity_metrics ADD CONSTRAINT similarity_metrics_pkey PRIMARY KEY (metric);
ALTER TABLE similarity.similarity_stats ADD CONSTRAINT similarity_stats_pkey PRIMARY KEY (metric);
ALTER TABLE similarity.eval_params ADD CONSTRAINT eval_params_pkey PRIMARY KEY (id);
ALTER TABLE similarity.eval_results ADD CONSTRAINT eval_results_pkey PRIMARY KEY (id);

COMMIT;
@@ -0,0 +1 @@
CREATE SCHEMA similarity;
@@ -156,4 +156,60 @@ CREATE TABLE feedback (
suggestion TEXT
);

CREATE TABLE similarity.similarity (
id INTEGER, -- PK, FK to lowlevel
mfccs DOUBLE PRECISION[] NOT NULL,
mfccsw DOUBLE PRECISION[] NOT NULL,
gfccs DOUBLE PRECISION[] NOT NULL,
gfccsw DOUBLE PRECISION[] NOT NULL,
key DOUBLE PRECISION[] NOT NULL,
bpm DOUBLE PRECISION[] NOT NULL,
onsetrate DOUBLE PRECISION[] NOT NULL,
moods DOUBLE PRECISION[] NOT NULL,
instruments DOUBLE PRECISION[] NOT NULL,
dortmund DOUBLE PRECISION[] NOT NULL,
rosamerica DOUBLE PRECISION[] NOT NULL,
tzanetakis DOUBLE PRECISION[] NOT NULL
);

CREATE TABLE similarity.similarity_metrics (
metric TEXT, -- PK
is_hybrid BOOLEAN,
description TEXT,
category TEXT,
visible BOOLEAN
);

CREATE TABLE similarity.similarity_stats (
metric TEXT,
means DOUBLE PRECISION[],
stddevs DOUBLE PRECISION[]
);

CREATE TABLE similarity.eval_params (
id SERIAL, -- PK
metric TEXT, -- FK to similarity_metrics
distance_type TEXT,
n_trees INTEGER
);
ALTER TABLE similarity.eval_params ADD CONSTRAINT unique_params_constraint UNIQUE(metric, distance_type, n_trees);

CREATE TABLE similarity.eval_results (
id SERIAL, -- PK
query_id INTEGER, -- FK to lowlevel
similar_ids INTEGER[],
distances DOUBLE PRECISION[],
params INTEGER -- FK to eval_params
);
ALTER TABLE similarity.eval_results ADD CONSTRAINT unique_eval_query_constraint UNIQUE(query_id, params);

CREATE TABLE similarity.eval_feedback (
user_id INTEGER, -- FK to user
eval_id INTEGER, -- FK to eval_results
result_id INTEGER,
rating similarity.eval_type,
suggestion TEXT
);
ALTER TABLE similarity.eval_feedback ADD CONSTRAINT unique_eval_user_constraint UNIQUE(user_id, eval_id, result_id);

COMMIT;
@@ -3,3 +3,4 @@ CREATE TYPE model_status AS ENUM ('hidden', 'evaluation', 'show');
CREATE TYPE version_type AS ENUM ('lowlevel', 'highlevel');
CREATE TYPE eval_location_type AS ENUM ('local', 'remote');
CREATE TYPE gid_type AS ENUM ('mbid', 'msid');
CREATE TYPE similarity.eval_type AS ENUM ('less similar', 'accurate', 'more similar');
@@ -0,0 +1,5 @@
BEGIN;

DROP SCHEMA IF EXISTS similarity CASCADE;

COMMIT;
@@ -0,0 +1,24 @@
BEGIN;

DROP TABLE IF EXISTS highlevel_model CASCADE;
DROP TABLE IF EXISTS highlevel_meta CASCADE;
DROP TABLE IF EXISTS highlevel CASCADE;
DROP TABLE IF EXISTS model CASCADE;
DROP TABLE IF EXISTS lowlevel_json CASCADE;
DROP TABLE IF EXISTS lowlevel CASCADE;
DROP TABLE IF EXISTS version CASCADE;
DROP TABLE IF EXISTS statistics CASCADE;
DROP TABLE IF EXISTS incremental_dumps CASCADE;
DROP TABLE IF EXISTS dataset_snapshot CASCADE;
DROP TABLE IF EXISTS dataset_eval_jobs CASCADE;
DROP TABLE IF EXISTS dataset_class_member CASCADE;
DROP TABLE IF EXISTS dataset_class CASCADE;
DROP TABLE IF EXISTS dataset CASCADE;
DROP TABLE IF EXISTS dataset_eval_sets CASCADE;
DROP TABLE IF EXISTS "user" CASCADE;
DROP TABLE IF EXISTS api_key CASCADE;
DROP TABLE IF EXISTS challenge CASCADE;
DROP TABLE IF EXISTS dataset_eval_challenge CASCADE;
DROP TABLE IF EXISTS feedback CASCADE;

COMMIT;
@@ -0,0 +1,9 @@
BEGIN;

DROP TYPE IF EXISTS eval_job_status CASCADE;
DROP TYPE IF EXISTS model_status CASCADE;
DROP TYPE IF EXISTS version_type CASCADE;
DROP TYPE IF EXISTS eval_location_type CASCADE;
DROP TYPE IF EXISTS gid_type CASCADE;

COMMIT;
@@ -0,0 +1,30 @@
BEGIN;

-- Add base metrics when db is initialized, before similarity stats are computed
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('mfccs', 'FALSE', 'MFCCs', 'timbre');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('mfccsw', 'FALSE', 'MFCCs (weighted)', 'timbre');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('gfccs', 'FALSE', 'GFCCs', 'timbre');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('gfccsw', 'FALSE', 'GFCCs (weighted)', 'timbre');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('key', 'FALSE', 'Key/Scale', 'rhythm');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('bpm', 'FALSE', 'BPM', 'rhythm');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('onsetrate', 'FALSE', 'OnsetRate', 'timbre');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('moods', 'FALSE', 'Moods', 'high-level');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('instruments', 'FALSE', 'Instruments', 'high-level');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('dortmund','FALSE', 'Genre (dortmund model)', 'high-level');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('rosamerica', 'FALSE', 'Genre (rosamerica model)', 'high-level');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('tzanetakis', 'FALSE', 'Genre (tzanetakis model)', 'high-level');

INSERT INTO similarity.eval_params (metric, distance_type, n_trees) VALUES ('mfccs', 'angular', 10);
INSERT INTO similarity.eval_params (metric, distance_type, n_trees) VALUES ('mfccsw', 'angular', 10);
INSERT INTO similarity.eval_params (metric, distance_type, n_trees) VALUES ('gfccs', 'angular', 10);
INSERT INTO similarity.eval_params (metric, distance_type, n_trees) VALUES ('gfccsw', 'angular', 10);
INSERT INTO similarity.eval_params (metric, distance_type, n_trees) VALUES ('key', 'angular', 10);
INSERT INTO similarity.eval_params (metric, distance_type, n_trees) VALUES ('bpm', 'angular', 10);
INSERT INTO similarity.eval_params (metric, distance_type, n_trees) VALUES ('onsetrate', 'angular', 10);
INSERT INTO similarity.eval_params (metric, distance_type, n_trees) VALUES ('moods', 'angular', 10);
INSERT INTO similarity.eval_params (metric, distance_type, n_trees) VALUES ('instruments', 'angular', 10);
INSERT INTO similarity.eval_params (metric, distance_type, n_trees) VALUES ('dortmund', 'angular', 10);
INSERT INTO similarity.eval_params (metric, distance_type, n_trees) VALUES ('rosamerica', 'angular', 10);
INSERT INTO similarity.eval_params (metric, distance_type, n_trees) VALUES ('tzanetakis', 'angular', 10);

COMMIT;
@@ -0,0 +1,64 @@
BEGIN;

CREATE SCHEMA similarity;

CREATE TABLE similarity.similarity (
id INTEGER, -- PK, FK to lowlevel
mfccs DOUBLE PRECISION[] NOT NULL,
mfccsw DOUBLE PRECISION[] NOT NULL,
gfccs DOUBLE PRECISION[] NOT NULL,
gfccsw DOUBLE PRECISION[] NOT NULL,
key DOUBLE PRECISION[] NOT NULL,
bpm DOUBLE PRECISION[] NOT NULL,
onsetrate DOUBLE PRECISION[] NOT NULL,
moods DOUBLE PRECISION[] NOT NULL,
instruments DOUBLE PRECISION[] NOT NULL,
dortmund DOUBLE PRECISION[] NOT NULL,
rosamerica DOUBLE PRECISION[] NOT NULL,
tzanetakis DOUBLE PRECISION[] NOT NULL
);

ALTER TABLE similarity.similarity ADD CONSTRAINT similarity_pkey PRIMARY KEY (id);

ALTER TABLE similarity.similarity
ADD CONSTRAINT similarity_fk_lowlevel
FOREIGN KEY (id)
REFERENCES lowlevel (id);

CREATE TABLE similarity.similarity_metrics (
metric TEXT, -- PK
is_hybrid BOOLEAN,
description TEXT,
category TEXT
);

ALTER TABLE similarity.similarity_metrics ADD CONSTRAINT similarity_metrics_pkey PRIMARY KEY (metric);
-- Add base metrics when db is initialized, before similarity stats are computed
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('mfccs', 'FALSE', 'MFCCs', 'timbre');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('mfccsw', 'FALSE', 'MFCCs (weighted)', 'timbre');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('gfccs', 'FALSE', 'GFCCs', 'timbre');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('gfccsw', 'FALSE', 'GFCCs (weighted)', 'timbre');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('key', 'FALSE', 'Key/Scale', 'rhythm');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('bpm', 'FALSE', 'BPM', 'rhythm');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('onsetrate', 'FALSE', 'MFCCs', 'timbre');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('moods', 'FALSE', 'Moods', 'high-level');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('instruments', 'FALSE', 'Instruments', 'high-level');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('dortmund','FALSE', 'Genre (dortmund model)', 'high-level');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('rosamerica', 'FALSE', 'Genre (rosamerica model)', 'high-level');
INSERT INTO similarity.similarity_metrics (metric, is_hybrid, description, category) VALUES ('tzanetakis', 'FALSE', 'Genre (tzanetakis model)', 'high-level');


CREATE TABLE similarity.similarity_stats (
metric TEXT, -- FK to metric
means DOUBLE PRECISION[],
stddevs DOUBLE PRECISION[]
);

ALTER TABLE similarity.similarity_stats ADD CONSTRAINT similarity_stats_pkey PRIMARY KEY (metric);

ALTER TABLE similarity.similarity_stats
ADD CONSTRAINT similarity_stats_fk_metric
FOREIGN KEY (metric)
REFERENCES similarity.similarity_metrics (metric);

COMMIT;
@@ -0,0 +1,63 @@
BEGIN;

CREATE TYPE similarity.eval_type AS ENUM ('less similar', 'accurate', 'more similar');

CREATE TABLE similarity.eval_params (
id SERIAL, -- PK
metric TEXT, -- FK to similarity_metrics
distance_type TEXT,
n_trees INTEGER
);

ALTER TABLE similarity.eval_params ADD CONSTRAINT unique_params_constraint UNIQUE(metric, distance_type, n_trees);
ALTER TABLE similarity.eval_params ADD CONSTRAINT eval_params_pkey PRIMARY KEY (id);

ALTER TABLE similarity.eval_params
ADD CONSTRAINT eval_params_fk_metric
FOREIGN KEY (metric)
REFERENCES similarity.similarity_metrics (metric);


CREATE TABLE similarity.eval_results (
id SERIAL, -- PK
query_id INTEGER, -- FK to lowlevel
similar_ids INTEGER[],
distances DOUBLE PRECISION[],
params INTEGER -- FK to eval_params
);

ALTER TABLE similarity.eval_results ADD CONSTRAINT unique_eval_query_constraint UNIQUE(query_id, params);
ALTER TABLE similarity.eval_results ADD CONSTRAINT eval_results_pkey PRIMARY KEY (id);

ALTER TABLE similarity.eval_results
ADD CONSTRAINT eval_results_fk_lowlevel
FOREIGN KEY (query_id)
REFERENCES lowlevel (id);

ALTER TABLE similarity.eval_results
ADD CONSTRAINT eval_results_fk_eval_params
FOREIGN KEY (params)
REFERENCES similarity.eval_params (id);


CREATE TABLE similarity.eval_feedback (
user_id INTEGER, -- FK to user
eval_id INTEGER, -- FK to eval_results
result_id INTEGER,
rating similarity.eval_type,
suggestion TEXT
);

ALTER TABLE similarity.eval_feedback ADD CONSTRAINT unique_eval_user_constraint UNIQUE(user_id, eval_id, result_id);

ALTER TABLE similarity.eval_feedback
ADD CONSTRAINT eval_feedback_fk_user
FOREIGN KEY (user_id)
REFERENCES "user" (id);

ALTER TABLE similarity.eval_feedback
ADD CONSTRAINT eval_feedback_fk_query_id
FOREIGN KEY (eval_id)
REFERENCES similarity.eval_results (id);

COMMIT;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.