March 2013 Archives

Programming in python

| 2 Comments
After two days full of reconciling my system to run python and iPython --- during which I "\rm -Rf"ed a directory that I shouldn't have --- things appear to be running. I went the way of enthought --- which is free for academic use, but then found it is only 32-bit on my 64-bit machine. (Peter Williams also points to Anaconda as an option.) So, I removed all of that, and used homebrew (also see here) to install python and all the libraries I was missing, and pip to install the packages I need. Now, ipython with the notebook looks like an awesome way to develop! There is also IDLE.

Now, here are some good resources:
I am giving a seminar this Friday March 15, at INRIA in Rennes, France. 11 AM, Room Sicile

Title: Evaluation

Abstract: Evaluation. Evaluating evaluations.* Evaluation of evaluations and assessments. Evaluation, examination, and evaluation of testing evaluations. Evaluation gauging, gauging evaluation evaluations, and evaluating evaluation evaluations. Evaluating. Evaluating evaluation and evaluation evaluating. Evaluations of evaluations and evaluating evaluation evaluations. Evaluation of evaluation appraisals, evaluation evaluation evaluation analysis, and assessing evaluation evaluating evaluation evaluations. Finally, evaluation testing, evaluating evaluation testing evaluations, and reviewing evaluation evaluation. Evaluation.**

* Evaluation.

** Evaluating evaluation and evaluations.

(NB: I discuss evaluation in music information research, with particular emphasis paid to music genre recognition, music mood recognition, and autotagging. I argue that most approaches to evaluating such algorithms have no internal and external experimental validity when one wishes to measure their _capacity for recognition_. The example of the horse Clever Hans suffices to illustrate this point. Algorithms can have very high classification accuracies by virtue of confounds, but current approaches to evaluation do not control for this.)

MPTK in Python: basics

| No Comments
Today, I begin looking at starting to begin what I need to do in order to start and reproduce my wivigram code from yesterday using the python scientific visualization library matplotlib. First, I download the dmg, and install it. Then I read the user guide. Then I see there is something called Enthought, which provides an all-in-one working python installation, and includes matplotlib! Then I see it costs money. Then I quickly return to the terminal.

So, in the terminal I type "python", and away we go! To lunch.

From MPTK books to Wivigrams

| No Comments
Here is a sonogram of the introduction to "Pictor Alpha" by Curtis Roads.

sonogram.png Now, we make a dictionary of Gabor atoms of various sizes, and decompose this signal into 5000 atoms using MPTK. How can we visualize the output? One of the easiest ways is by a superposition of the Wigner-Ville distributions of the atoms, scaled by their energy in the decomposition. This produces the following picture.

wivigram.png The code I used to generate this is here. Much more can be done to the code by way of software engineering to streamline it; but it is only to serve as a simple example of how to do such visualizations.

Now, time to look at doing the same but in python.
Wait no longer! In 2010, I chronicled my installation of MPTK 0.5.3 on Mac OS X 10.6.4. Now, I do so for MPTK 0.6.1 on OS X 10.7.5.

First, download the sources from here. While unpacking, I get some ice tea and think about the good old days. Now, let's say I just want to build and install the package from the command line.
  1. I create a directory "mkdir MPTK061"; and "cd MPTK061".
  2. Then I "cmake PATH_TO_SOURCE/MPTK-Source-0.6.1/".
  3. We might need to adjust some things, but we need to generate the make script. So, I type "ccmake ." If you don't have MATLAB installed, turn off "BUILD_MATLAB_MEX_FILES". I leave mine on. Then I hit "c" for configuring, and "g" for generating.
  4. Then I type "make".
  5. Then I get errors:
    In file included from /usr/local/include/mptk.h:295,
                     from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/classes/mptk4matlab.h:32,
                     from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/bookread.cpp:45:
    /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/mp_system.h:101:1: warning: "ULONG_MAX" redefined
    In file included from /usr/include/machine/limits.h:6,
                     from /usr/include/limits.h:64,
                     from /Applications/MATLAB_R2010b.app/extern/include/tmwtypes.h:43,
                     from /Applications/MATLAB_R2010b.app/extern/include/matrix.h:293,
                     from /Applications/MATLAB_R2010b.app/extern/include/mex.h:59,
                     from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/classes/mptk4matlab.h:31,
                     from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/bookread.cpp:45:
    /usr/include/i386/limits.h:75:1: warning: this is the location of the previous definition
    In file included from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/classes/mptk4matlab.h:32,
                     from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/bookread.cpp:45:
    /usr/local/include/mptk.h:3204: error: 'GP_Pos_Book_c' has not been declared
    /usr/local/include/mptk.h:3212: error: 'GP_Param_Book_c' has not been declared
    /usr/local/include/mptk.h:3231: error: 'GP_Book_c' has not been declared
    /usr/local/include/mptk.h:3232: error: 'GP_Book_c' has not been declared
    /usr/local/include/mptk.h:3238: error: 'GP_Param_Book_c' has not been declared
    /usr/local/include/mptk.h:3239: error: 'GP_Param_Book_c' has not been declared
    In file included from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/classes/mptk4matlab.h:32,
                     from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/bookread.cpp:45:
    /usr/local/include/mptk.h:4272: error: 'GP_Block_Book_c' has not been declared
    In file included from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/classes/mptk4matlab.h:32,
                     from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/bookread.cpp:45:
    /usr/local/include/mptk.h:4914: error: 'GP_Pos_Book_c' has not been declared
    /usr/local/include/mptk.h:5109: error: 'GP_Pos_Book_c' has not been declared
    /usr/local/include/mptk.h:5244: error: 'GP_Pos_Book_c' has not been declared
    /usr/local/include/mptk.h:5680: error: 'GP_Pos_Book_c' has not been declared
    In file included from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/classes/mptk4matlab.h:32,
                     from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/bookread.cpp:45:
    /usr/local/include/mptk.h:7731: error: ISO C++ forbids declaration of 'GP_Pos_Range_Sub_Book_c' with no type
    /usr/local/include/mptk.h:7731: error: 'GP_Pos_Range_Sub_Book_c' declared as a 'virtual' field
    /usr/local/include/mptk.h:7731: error: expected ';' before '*' token
    In file included from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/classes/mptk4matlab.h:32,
                     from /Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/bookread.cpp:45:
    /usr/local/include/mptk.h:7990: error: ISO C++ forbids declaration of 'GP_Pos_Range_Sub_Book_c' with no type
    /usr/local/include/mptk.h:7990: error: 'GP_Pos_Range_Sub_Book_c' declared as a 'virtual' field
    /usr/local/include/mptk.h:7990: error: expected ';' before '*' token
    /usr/local/include/mptk.h:7997: error: ISO C++ forbids declaration of 'GP_Pos_Range_Sub_Book_c' with no type
    /usr/local/include/mptk.h:7997: error: 'GP_Pos_Range_Sub_Book_c' declared as a 'virtual' field
    /usr/local/include/mptk.h:7997: error: expected ';' before '*' token
    /usr/local/include/mptk.h:8005: error: ISO C++ forbids declaration of 'GP_Pos_Range_Sub_Book_c' with no type
    /usr/local/include/mptk.h:8005: error: 'GP_Pos_Range_Sub_Book_c' declared as a 'virtual' field
    /usr/local/include/mptk.h:8005: error: expected ';' before '*' token
    
        mex: compile of ' "/Users/bobs/Aalborg/research/201303/MPTK-Source-0.6.1/src/matlab/bookread.cpp"' failed.
    
    make[2]: *** [mptk/matlab/bookread.mexmaci64] Error 1
    make[1]: *** [src/matlab/CMakeFiles/matlab_bookread.dir/all] Error 2
    make: *** [all] Error 2
  6. WHAT IS GOING ON?!???
  7. Ten minutes later, calmly note that my path still has the old version of MPTK.
  8. So I delete /usr/local/include/mptk.h: "sudo rm /usr/local/include/mptk.h". Password: "*********"
  9. Then I type "make" again; and to install it "sudo make". Password: "****"
Now, let's say I want to create an XCode project.
  1. I create a directory "mkdir MPTK061"; and "cd MPTK061".
  2. Then I "cmake -G Xcode PATH_TO_SOURCE/MPTK-Source-0.6.1/".
  3. Now, I "ccmake .", adjust any settings, configure and generate as above.
  4. This creates in the path, "MPTK.xcodeproj", which I open in XCode.
  5. I select the ALL BUILD, hit run, and get errors:
    -> gcc -O -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2010b.app/extern/lib/maci64/mexFunction.map -o  "/Users/bobs/Aalborg/research/201303/MPTK061/mptk/matlab/dictread.mexmaci64"  /Users/bobs/Aalborg/research/201303/MPTK061/mptk/matlab/dictread.o  -L/Users/bobs/Aalborg/research/201303/MPTK061/lib -lmptk -lmptk4matlab -L/Applications/MATLAB_R2010b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
    
    ld: library not found for -lmptk
    collect2: ld returned 1 exit status
    
        mex: link of ' "/Users/bobs/Aalborg/research/201303/MPTK061/mptk/matlab/dictread.mexmaci64"' failed.
    
    make: *** [/Users/bobs/Aalborg/research/201303/MPTK061/mptk/matlab/dictread.mexmaci64] Error 1
    Command /bin/sh failed with exit code 2
    
  6. This looks to be a linking error, and I currently don't know how to solve it.
Today, I am testing the discrimination ability of the sparse representation classifier (SRC) using auditory temporal modulations (ATMs) using the CAL500 dataset. The first application to autotagging of such features and such machine learning is: Y. Panagakis, C. Kotropoulos, and G. R. Arce, "Sparse multi-label linear embedding nonnegative tensor factorization for automatic music tagging," in Proc. EUSIPCO, (Aalborg, Denmark), pp. 492-496, Aug. 2010. Here, we take SRC and apply ATMs (derivation described in B. L. Sturm, "Two systems for automatic music genre recognition: What are they really recognizing?," in Proc. ACM MIRUM Workshop, (Nara, Japan), Nov. 2012. We also normalize the features such that each dimension is mapped to [0,1].) To decide on the emotional label of a song, which has several ATMs, we pick the class giving the lowest sum of the errors over all frames.

When I create classes based on the tags:

tagsinclass1 = {'Emotion-Happy'};
tagsinclass2 = {'Emotion-Sad'};
I get the following statistics:

meansongaccuracy =

    0.7254

normsongaccuracy =

    0.6562

 	  SONG TRUE 
 	 H 	 S 	
 H 	 0.83 	 0.52
 S 	 0.17 	 0.48
 	--- CLASS --- 
 Recall	 0.83	 0.48 
 Prec.	 0.79	 0.55 
 F   	 0.81	 0.51 
When I create classes based on the tags:

tagsinclass1 = {'Emotion-Happy','NOT-Emotion-Sad'};
tagsinclass2 = {'Emotion-Sad','NOT-Emotion-Happy'};
and select only those excerpts that have 1 in both, I get the following statistics:

meansongaccuracy =

    0.7091

normsongaccuracy =

    0.6517

 	  SONG TRUE 
 	 H 	 S 	
 H 	 0.79 	 0.49
 S 	 0.21 	 0.51
 	--- CLASS --- 
 Recall	 0.79	 0.51 
 Prec.	 0.79	 0.51 
 F   	 0.79	 0.51 
Looks like we have an ok "happy" tagger, but its ability to choose "sad" is random.

Using the CAL500 dataset?

| 1 Comment
A popular dataset to use in music autotagging is CAL500. It is described as coming from "500 songs." When we download the soundfiles, we find 500 songs; but when we look at the song names, we find 502 titles. Even more puzzling, if we look at the Echo Nest IDs, we find 503 titles! After some digging around, I found the problems, and a few others. There is no information about these discrepancies on-line, so below I present the problems and solutions.

  1. The extra title in the Echo Nest IDs is: "pink_floyd-echoes_15 TRQVSAX12527819B19." Because there already is "pink_floyd-echoes TRBCHNJ1251AE42CB9", I remove it from this file.
  2. The two songs missing from the soundfiles are: "crosby_stills_and_nash-guinnevere TRALRAI1251FD19699" and "radiohead-karma_police TRZEWZE1251AE72E42". I have obtained them through other means, and upload them here.
  3. The mp3 file "jade_leary-going_in.mp3" is only 313 bytes. It is 21 seconds in reality, so I was able to download the entire "song" from amazon. I upload it here.
  4. The mp3 file "frank_zappa-whats_the_ugliest_part_of_your_body.mp3" is 2 seconds long. We download the entire song from YouTube. I upload it here.
  5. The mp3 file "guided_by_voices-kicker_of_elves.mp3" is 4 seconds long. We download the entire song from YouTube. I upload it here.
  6. The mp3 file "jackalopes-rotgut.mp3" is 3 seconds long. We download the entire song from YouTube. I upload it here.
  7. In "songnames.txt" we find the first few files listed in an order that is different from what we get when using a "dir" or "ls" command. It is also different from the order listed in the Echo Nest IDs. So, we assume that the order of the 502 sets of annotations in "hardAnnotations.txt" and "softAnnotations.txt" is that given in "songnames.txt".

Blog Roll

About this Archive

This page is an archive of entries from March 2013 listed from newest to oldest.

February 2013 is the previous archive.

April 2013 is the next archive.

Find recent content on the main index or look in the archives to find all content.