[Invitation to open collaboration] Practice what we learned in lec 3, learn more about ipywidgets and voila

thank you, It helps… if you check the link at the very bottom of the page there is an other example… but I can not dig the source - lack of my knowledge how to do it. :slight_smile:

Thanks @radek! Now we’re getting wild :stuck_out_tongue:

1 Like

A good strategy might be trying to run the code in that notebook and seeing if you can modify it to fit your needs. But yes, you are right, this probably goes a little bit above just a simple case of adding widgets to the notebook.

Here is a blog post on relative vs absolute paths, maybe this can be helpful. Probably you want to point the href attribute to the name of the notebook you would like to link to. In its simplest form, if you have two notebooks in a single directory, notebook a.ipynb and b.ipynb, if you want to link from b to a, you could just open a cell, change it into a markdown cell (as opposed to a code one, by pressing m or doing so in the drop down)
image

and type this:

[link to a]('a.ipynb')

and upon executing that cell you should have a working link (like in the image I am attaching).

Not sure if this is helpful, but nothing else comes to mind :slight_smile: I believe anything you would do using ipywidgets on top of this would be just making it prettier / having some programatic way of creating these links, based on ids or whatnot.

@radek, I’m not sure if I quite understand Task #1 here. I can hear the audio samples of the ambiguous labels but I don’t have any examples of the correct labels (Thuk and Tuck). How can I say which category the ambiguous labelled calls belong to when I don’t know how the correct labels sound like? I can only guess from the spellings what the mistakes could’ve been while labelling. E.g.:

  1. Thuk: ThuC, ThuckC and ThukC
  2. Tuck: TukC

Or, by hearing the ambiguous labels, I could try to group them into two groups but then I can’t say which of them is which correct label.
Have I missed something?

I think you are right :slight_smile: This is a bit of an open ended question. Trying to work off the spellings sounds to me like a viable option. Another thing worth considering is that the names of the calls often describe the vocalization you are hearing. In the case of macaques, a coo call is literally the macaque making a coo sound :slight_smile:

I know that in English, especially for non native speakers (if you ever heard my accent you would know I am very much in that boat :slight_smile: ) it can be quite challenging to tell between the words thuk and tuck. But that is also another way to approach this.

I think it’s okay to not get this right, would be great though to hear how you and others get on with this task :slight_smile:

What might be helpful, and I am very sorry for not including this initially, is the full list of possible calls, their names. Indeed with just th and tu it is really hard to figure out what is going on. Maybe knowing one is looking for thuk and tuck can make things a little bit more tractable.

Thanks so much for looking into this Gautam!

image

1 Like

Thanks for the clarification Radek!
Might I just add how and why I guessed it that way?
Many Indian languages differentiate between a th and t sound (in fact, Hindi has four different T sounds, and additionally, four different D sounds).
That’s why I guessed the way I did.

1 Like

Definitely interested in learning more about ipywidgets and voila, used ipywidgets exclusively in this project
Visual GUI.

There is a lot of potential in creating usable interactive interfaces with ipywidgets, voila and binder(CPU is just fine for data and augmentation visualizations).

Although I did get a comment on another forum(not fastai) ‘Didn’t realize people are still using ipywidets’ :slight_smile: :grimacing:

1 Like

My guesses for Task #2 (this is definitely the simplest possible guess but I couldn’t really convince myself to guess differently after listening to many calls).

type2labels = {
   'Ag': ['Ag', 'AggC'],
   'Be': ['BeggSeq', 'Beggseq'],
   'DC': ['DC'],
   'Di': ['DisC'],
   'LT': ['LTC'],
   'Ne': ['Ne', 'NeArkC', 'NeKakleC', 'NeSeq', 'NekakleC', 'NestC', 'NestCSeq', 'NestCseq', 'NestSeq'],
   'So': ['So', 'Song'],
   'Te': ['Te', 'Tet', 'TetC'],
   'Th': ['ThuC', 'ThuckC', 'ThukC'],
   'Tu': ['TukC'],
   'Wh': ['WC', 'Wh', 'Whi', 'WhiC', 'WhiCNestC', 'Whine', 'WhineC', 'WhineCSeq']
}
1 Like

Nice new project Radek!

Based on spellings (like Gautam_e)
Task1
“Th” : [ ‘ThuC’, ‘ThuckC’, ‘ThukC’],
“Tu” : [‘TukC’]

Listening to the TukC sounds I do not hear any difference with the Th* sounds. Maybe group then as one?

1 Like

For Task #3 I’ve added two lines to @radek’s code to show the spectrogram, the length of the file and the filename to yield something like this:
image

Unfortunately, I’m struggling with binder to host the app. I was able to get an output from voila, but on following the instructions for hosting the app on Binder I get a “404: File not found” error.
I’d be happy to see anyone else’s results.

1 Like

Thank you very much for all your help on the relabeling. :slight_smile:

I went through this exercise myself and will be going with your suggestions, that is a mapping like in the post from @gautam_e:

type2labels = {
   'Ag': ['Ag', 'AggC'],
   'Be': ['BeggSeq', 'Beggseq'],
   'DC': ['DC'],
   'Di': ['DisC'],
   'LT': ['LTC'],
   'Ne': ['Ne', 'NeArkC', 'NeKakleC', 'NeSeq', 'NekakleC', 'NestC', 'NestCSeq', 'NestCseq', 'NestSeq'],
   'So': ['So', 'Song'],
   'Te': ['Te', 'Tet', 'TetC'],
   'Th': ['ThuC', 'ThuckC', 'ThukC'],
   'Tu': ['TukC'],
   'Wh': ['WC', 'Wh', 'Whi', 'WhiC', 'WhiCNestC', 'Whine', 'WhineC', 'WhineCSeq']
}

The one additional piece of information that played into discrimination of Th and Tu is this table from the paper:
image

The counts are aligned with your interpretation based on misspellings.

I have now inverted the dictionary and will be using it to relabel the examples:

2 Likes

I’m running the downloading_and_processing_of_data notebook and got an error.

df.call_type = df.call_type.apply(lambda x: labels2type[x])

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-45-a36040f6c228> in <module>
----> 1 df.call_type = df.call_type.apply(lambda x: labels2type[x])

/opt/conda/envs/fastai/lib/python3.6/site-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds)
   3192             else:
   3193                 values = self.astype(object).values
-> 3194                 mapped = lib.map_infer(values, f, convert=convert_dtype)
   3195 
   3196         if len(mapped) and isinstance(mapped[0], Series):

pandas/_libs/src/inference.pyx in pandas._libs.lib.map_infer()

<ipython-input-45-a36040f6c228> in <lambda>(x)
----> 1 df.call_type = df.call_type.apply(lambda x: labels2type[x])

KeyError: 'C'

There is no ‘C’ in labels2type
{‘Ag’: ‘Ag’, ‘AggC’: ‘Ag’, ‘BeggSeq’: ‘Be’, ‘Beggseq’: ‘Be’, ‘DC’: ‘DC’, ‘DisC’: ‘Di’, ‘LTC’: ‘LT’, ‘Ne’: ‘Ne’, ‘NeArkC’: ‘Ne’, ‘NeKakleC’: ‘Ne’, ‘NeSeq’: ‘Ne’, ‘NekakleC’: ‘Ne’, ‘NestC’: ‘Ne’, ‘NestCSeq’: ‘Ne’, ‘NestCseq’: ‘Ne’, ‘NestSeq’: ‘Ne’, ‘So’: ‘So’, ‘Song’: ‘So’, ‘Te’: ‘Te’, ‘Tet’: ‘Te’, ‘TetC’: ‘Te’, ‘ThuC’: ‘Th’, ‘ThuckC’: ‘Th’, ‘ThukC’: ‘Th’, ‘TukC’: ‘Tu’, ‘WC’: ‘Wh’, ‘Wh’: ‘Wh’, ‘Whi’: ‘Wh’, ‘WhiC’: ‘Wh’, ‘WhiCNestC’: ‘Wh’, ‘Whine’: ‘Wh’, ‘WhineC’: ‘Wh’, ‘WhineCSeq’: ‘Wh’}

So this label shoud be removed right ?

[Update] I checked what is the filename for label C and found it should be Nest. Example: |861|BlaLbl8026_110608-Nest-C-13.wav|True|blalbl8026|NaT|C|13| . So I will manually change the 2 files which are wrong labeled.

I’ve just created a PR which adding just call_type[869] = 'Ne'; call_type[1663] = 'Ne' . However, I think that maybe I should do something to clean the notebook. Because now it creates many changes in metadata (for examples the order of executed cells, python version, …). You can accept it or I will review what I need to do for making change notebook.

1 Like

Thank you again Dien-Hoa for your PR and post! I just redownloaded the data and rerun the entire notebook and I am not seeing any C labels?

These are the only labels that I see:

['Ag',
 'AggC',
 'BeggSeq',
 'Beggseq',
 'DC',
 'DisC',
 'LTC',
 'Ne',
 'NeArkC',
 'NeKakleC',
 'NeSeq',
 'NekakleC',
 'NestC',
 'NestCSeq',
 'NestCseq',
 'NestSeq',
 'So',
 'Song',
 'Te',
 'Tet',
 'TetC',
 'ThuC',
 'ThuckC',
 'ThukC',
 'TukC',
 'WC',
 'Wh',
 'Whi',
 'WhiC',
 'WhiCNestC',
 'Whine',
 'WhineC',
 'WhineCSeq']

Would you please be so kind and doublecheck you are working from unmodified data, and if you are could you please provide a bit of information which rows are affected? (or which file names? that might make it easier to track what is going on).

Thank you so much again for all your efforts on this! Appreciate it!

I’ve just clone the project this afternoon. After redownloading the data, I still get the error.

Running df[df.call_type == ‘C’] I get result as below

fn adult name date_recorded call_type rendition_num
861 BlaLbl8026_110608-Nest-C-13.wav True blalbl8026 NaT C 13
1647 BlaLbl8026_110608-Nest-C-14.wav True blalbl8026 NaT C 14

So I think with the names above, this patter re.compile('(.*)_(.*)[-_](.*)-(.*)\.wav') create correctly the ‘C’ label

2 Likes

Wow, you are right! :slight_smile: But the thing is that I am already correcting this! (I just forgot I was fixing it):

I think what is happening, is that somehow our OSes are reading the files in in different order. I am on Linux, are you on Mac or Windows by any chance?

I am hoping I fixed this now, by adding sorting of the paths after reading them in. If you were so kind, could you please pull from the repo and see if the code works for you now?

Thx a lot for all your help on this!

1 Like

I use Paperspace instance so I think the OS is linux. I will try what you suggest later. I’m very happy that it can help

1 Like

The problem is solved !

1 Like

Hi, I’ve tried to use the vanilla notebook from the coo repo and get the error rate ~ 4 to 7% after around 15 epochs.

And the most_confused:
interp.most_confused(min_val=2)
[(‘Song’, ‘Nest’, 5),
(‘Tuck’, ‘Nest’, 5),
(‘Begging’, ‘Long Tonal’, 2),
(‘Nest’, ‘Whine’, 2),
(‘Whine’, ‘Nest’, 2)]

It seems the “Thuk, Tuck” are actually not so confused than the Nest one.

@radek, for the Task#5 .what do you mean by unsupervised way ? I’m thinking about working on this task and I think that I still need the label. I summarize what I will do as below:

  • Run a Siamese network to extract feature (I read before that with matching model like Siamese we will have better feature to cluster, than classification model like resnet)
  • Run clustering model (ex DBscan) through all the data to find the clusters and extract the anomaly sample. Or Running directly Anomaly Detection (ex Isolation Forest) in just one class to detect the anomaly sample

Do you have any suggestion ?

Thanks

2 Likes

This is absolutely brilliant! Awesome work :slight_smile:

I think you are on the right track. My thinking was just an extension of what we learned in the class, how Jeremy was using the model to improve the data for the bear classifier. The idea is that the examples that the model gets wrong, or where it is most confused about, that maybe they are worth taking a look at, maybe they were mislabled or they are low quality or whatnot.

Task #5 could a precursor to this in some way. You could do something like I do here

Those are UMAP 2d embeddings obtained in an unsupervised way for the macaque coo calls. Quite a nice separation despite the algorithm not being informed of labels. Is there something similar you could do for the zebra_finch dataset? Do the calls from chicks and adults differ in some obvious way? What if you obtain embeddings from a classifier / siamese network? Are they better in some sense? How do you measure this? If you are training a model on spectrograms, which frequencies are most telling when it comes to discerning calls / bird identities? Would training a CAM model provide some useful insights? (CAM models are introduced in the fastbook

I think the biggest question is what angle of exploration you would find fun and interesting.

As a side note, its quite interesting to compare the results you are getting from the results in the paper :wink:

This is very useful! :blush: Have you tried listening to the calls? Do they sound to you like they might be misclassified? Quite a relief that the model seems to be happy with our tuck vs thuk split :slight_smile:

Does the error rate vary depending on the train - val split? Or is there something different about the training that you are doing? If you use the same validation set, what can you do to absolutely squeeze the most performance out of your single model? What if you were to take an ensemble of models, how does that differ? BTW how are you accommodating the different lengths of the calls? What are some other ways one could approach this and would it perform better?

Maybe some of these questions will be interesting to you, maybe not :slight_smile: Or maybe they will push you in a direction that is interesting to you :slight_smile: No clue :slight_smile: Exploring either of these directions can be extremely useful though especially if you can start creating some narrative around what you are exploring and what your findings are, and trying to tell the story through your notebooks.

I am also wondering if maybe we could try to identify individuals, if there is any hope on that. There is some information on that in the paper. If we have some nice way of framing this, that might be a really tough challenge, an open ended question in many regards as to how best to approach this.

Sorry, I do not have the answers myself, great to discuss ideas with you though :pray: And thank you for sharing all your wonderful work and findings!

2 Likes

I really really appreciate your help Radek. I think I have several ideas for myself.

You know, I think i’m kind of easily loosing motivation or lack of tenacity when I’m working alone (and it’s usually the case). However, I’m very interesting in sharing my knowledge to others. Now I have an idea of creating notebook that really telling the story how I’m learning. A emotional story is always attracting me more than a pure technical article.

Thanks again for your help and hoping me can really go to the end of this fastai course.

2 Likes