Answers.Body: <p><strong>Technically, you're not really doing classification</strong> The outputs you have are <em>not</em> labels, they are real values. So I've got two (possible!) solutions, and you'll have to test them out for yourself:</p>
  
  <h3>Solution 1</h3>
  
  <p>Because each output is actually a numerical value, you can normalize them just like you would normalize all other numerical values. So you choose a maximum value that you would expect for the labels (you can also do this per label), and divide the actual value by that value to normalize it.</p>
  
  <p>So if you don't expect more than 10 of the same amino acids in each peptide sequence, then you divide all amounts by 10:</p>
  
  <pre><code>0 becomes 0.0
  1 becomes 0.1
  2 becomes 0.2
  3 becomes 0.3
  etc.
  </code></pre>
  
  <h3>Solution 2</h3>
  
  <p>This is more complex, but if you'd give it a try it would surely work. <em>This solution requires recurrent networks</em>. Just like <a href="http://colah.github.io/posts/2015-08-Understanding-LSTMs/" rel="nofollow noreferrer">LSTM</a> networks are good for character-by-character text prediction, they will work for your 'peptide sequence language' as well.</p>
  
  <p>This solution also allows an output sequence of <em>any</em> length.</p>
  
  <p>How it works? You have a network with óne output (m/z), and 22 outputs (one-hot encoded amino acids) + 1 more, when this output has the highest value it tells you that the sequence has finished. </p>
  
  <p>You keep on inputting the same value of m/z, until your network tells that the sequence has finished. The network will output different letters every activation based on the previous outputs (the LSTM model has some kind of memory).</p>
  
  <p>This solution is kind of hard to explain, but if you provide me with a small list of peptide sequences (not too long, and not too much), then i'll make a working online example of you.</p>
  
  <hr>
  
  <p>As promised, I made simple implementation of solution 2. However, I think you should go for solution 1 anyways. I didn't have any <em>real</em> data, so my model is basically overfitting, but it basically works: <a href="https://jsfiddle.net/ovpkL2xx/2/" rel="nofollow noreferrer">https://jsfiddle.net/ovpkL2xx/2/</a> (might take some time to run)</p>
  
  <p>Made with <a href="https://github.com/wagenaartje/neataptic" rel="nofollow noreferrer">Neataptic</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-09T17:17:34.663Z
Answers.Text: thank you so much! I'll follow your advice. Unfortunately, I cannot provide you with any data due to patient confidentiality. I'll see if I can find any public examples.
Answers.UserDisplayName: rajkarthikkumar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-09T17:23:37.987Z
Answers.Text: @rajkarthikkumar I understand, just any simple peptide sequences and their m/z value is enough. (also provide all the different amino acids letters)
Answers.UserDisplayName: Thomas Wagenaar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-09T17:50:19.833Z
Answers.Text: http://www.fao.org/docrep/004/y2775e/y2775e0e.htm (all the one-letter codes for the amino acids)
Answers.UserDisplayName: rajkarthikkumar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-09T17:52:09.637Z
Answers.Text: @rajkarthikkumar that will do, I'll just make some sequences and their m/z values up
Answers.UserDisplayName: Thomas Wagenaar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-09T20:19:44.753Z
Answers.Text: @rajkarthikkumar I tried solution #2, unfortunately it is very hard to get a good error as my 'made up data' doesn't really have any correlations. So I'm going to try solution #1 somewhere soon, should work better
Answers.UserDisplayName: Thomas Wagenaar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-09T20:38:05.993Z
Answers.Text: I found a website with public spectra data. http://www.massbank.jp/QuickSearch.html If you search up, for example, Tyrosine, you get a list of example spectra http://www.massbank.jp/jsp/Dispatcher.jsp?type=disp&id=KO002701&site=0
Answers.UserDisplayName: rajkarthikkumar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-12T20:41:09.057Z
Answers.Text: Do you mind if you send me your implementation of the LSTM? I'm struggling to see how to piece it together.
Answers.UserDisplayName: rajkarthikkumar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-12T21:07:51.500Z
Answers.Text: Sorry! I started on it but it got out of my head. Ill send something tomorrow !
Answers.UserDisplayName: Thomas Wagenaar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-13T10:48:18.217Z
Answers.Text: @rajkarthikkumar updated the question
Answers.UserDisplayName: Thomas Wagenaar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-09T17:03:20.730Z
Answers.LastActivityDate: 2017-06-13T10:48:08.240Z
Answers.LastEditDate: 2017-06-13T10:48:08.240Z
Answers.UserDisplayName: Thomas Wagenaar
Body: <p>I am looking to train a dataset that would output a sequence of letters (I'm using this for peptide sequences). Since I have 22 different possibilities of amino acids, I need to output a vector that contains multiple amino acids with varying frequencies. For example, an output would look like [0,1,3,2,0,2,0,3...] (a 22-long vector).</p>
  
  <p>How can I train a neural network to output that type of vector?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-17T21:08:29.920Z
Comments.Text: Please, edit this post to ask an actual clear question.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-09T15:00:06.450Z
Comments.Text: What exactly does your output relate to? I don't understand what _3_ or _2_ is in your output, could you explain?
Comments.UserDisplayName: Thomas Wagenaar
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-09T15:34:29.973Z
Comments.Text: @ThomasW Since each peptide sequence has multiple amino acids of the same time, a 3 could represent 3 Ws. For example let's say my peptide sequence is WYTWXTGW, my output vector would have to account for the frequency of each amino acid.
Comments.UserDisplayName: rajkarthikkumar
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-09T15:43:39.967Z
Comments.Text: this doesn't make sense. If you output the frequency of letters, then how do you know the actual sequence? And more importantly, what is your input for this output?
Comments.UserDisplayName: Thomas Wagenaar
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-09T15:56:32.977Z
Comments.Text: Sorry for the confusion, but the actual sequence is part of the labeled dataset. This is a supervised problem. The input is spectra data that is labeled with a peptide sequence (and thus its corresponding amino acids). The actual data is represented in terms of m/z (a numerical number for spectra data). So if the number is (hypothetically) 4321.32, the peptide sequence could be WYTWXTGW. I want to train a neural network that takes in this information so when it is presented with unlabeled spectra data (after training), it can provide the peptide sequence.
Comments.UserDisplayName: rajkarthikkumar
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-09T16:04:28.190Z
Comments.Text: Oke, the second part helped me understand the problem. If I manage to think of an answer I'll post it. **But**, I still don't understand the first part. Let's say you only have 2 different aminoacids: A and B. So output would be [x, y]. Say you have output [2,1]. How would you know if the sequence is AAB, ABA or BAA? That's my problem  with this :) - i'm not a biological expert, but there are different peptide sequences with the same amount of certain amino acids, right?
Comments.UserDisplayName: Thomas Wagenaar
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-09T16:06:53.670Z
Comments.Text: Yes you are correct. There is no real way for me to tell the order after the the network is trained by I hope to just output the frequency for now :) . You are also correct that there are different sequences with the same amount of certain amino acids.
Comments.UserDisplayName: rajkarthikkumar
Tags: <neural-networks><machine-learning><deep-learning><classification>
Title: Multi-label Classification with non-binary outputs
UserDisplayName: rajkarthikkumar
ThreadText: # Multi-label Classification with non-binary outputs
  
  (Asked by: username_0 on 2017-06-08)
  
  I am looking to train a dataset that would output a sequence of letters (I'm using this for peptide sequences). Since I have 22 different possibilities of amino acids, I need to output a vector that contains multiple amino acids with varying frequencies. For example, an output would look like [0,1,3,2,0,2,0,3...] (a 22-long vector).
  
  How can I train a neural network to output that type of vector?
  
  **Tags:** neural-networks, machine-learning, deep-learning, classification
  > **Comments:**
  > **username_2**: What exactly does your output relate to? I don't understand what _3_ or _2_ is in your output, could you explain?  
  > **username_0**: @ThomasW Since each peptide sequence has multiple amino acids of the same time, a 3 could represent 3 Ws. For example let's say my peptide sequence is WYTWXTGW, my output vector would have to account for the frequency of each amino acid.  
  > **username_2**: this doesn't make sense. If you output the frequency of letters, then how do you know the actual sequence? And more importantly, what is your input for this output?  
  > **username_0**: Sorry for the confusion, but the actual sequence is part of the labeled dataset. This is a supervised problem. The input is spectra data that is labeled with a peptide sequence (and thus its corresponding amino acids). The actual data is represented in terms of m/z (a numerical number for spectra data). So if the number is (hypothetically) 4321.32, the peptide sequence could be WYTWXTGW. I want to train a neural network that takes in this information so when it is presented with unlabeled spectra data (after training), it can provide the peptide sequence.  
  > **username_2**: Oke, the second part helped me understand the problem. If I manage to think of an answer I'll post it. **But**, I still don't understand the first part. Let's say you only have 2 different aminoacids: A and B. So output would be [x, y]. Say you have output [2,1]. How would you know if the sequence is AAB, ABA or BAA? That's my problem  with this :) - i'm not a biological expert, but there are different peptide sequences with the same amount of certain amino acids, right?  
  > **username_0**: Yes you are correct. There is no real way for me to tell the order after the the network is trained by I hope to just output the frequency for now :) . You are also correct that there are different sequences with the same amount of certain amino acids.  
  > **username_1**: Please, edit this post to ask an actual clear question.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-06-09. Score: 2 | Accepted answer
  
  Technically, you're not really doing classification The outputs you have are not labels, they are real values. So I've got two (possible!) solutions, and you'll have to test them out for yourself:
  Solution 1
  Because each output is actually a numerical value, you can normalize them just like you would normalize all other numerical values. So you choose a maximum value that you would expect for the labels (you can also do this per label), and divide the actual value by that value to normalize it.
  So if you don't expect more than 10 of the same amino acids in each peptide sequence, then you divide all amounts by 10:
  0 becomes 0.0
  1 becomes 0.1
  2 becomes 0.2
  3 becomes 0.3
  etc.
  
  Solution 2
  This is more complex, but if you'd give it a try it would surely work. This solution requires recurrent networks. Just like LSTM networks are good for character-by-character text prediction, they will work for your 'peptide sequence language' as well.
  This solution also allows an output sequence of any length.
  How it works? You have a network with óne output (m/z), and 22 outputs (one-hot encoded amino acids) + 1 more, when this output has the highest value it tells you that the sequence has finished. 
  You keep on inputting the same value of m/z, until your network tells that the sequence has finished. The network will output different letters every activation based on the previous outputs (the LSTM model has some kind of memory).
  This solution is kind of hard to explain, but if you provide me with a small list of peptide sequences (not too long, and not too much), then i'll make a working online example of you.
  
  As promised, I made simple implementation of solution 2. However, I think you should go for solution 1 anyways. I didn't have any real data, so my model is basically overfitting, but it basically works: https://jsfiddle.net/ovpkL2xx/2/ (might take some time to run)
  Made with Neataptic
  
  > **Comments:**
  > **username_0**: thank you so much! I'll follow your advice. Unfortunately, I cannot provide you with any data due to patient confidentiality. I'll see if I can find any public examples.  
  > **username_2**: @rajkarthikkumar I understand, just any simple peptide sequences and their m/z value is enough. (also provide all the different amino acids letters)  
  > **username_0**: http://www.fao.org/docrep/004/y2775e/y2775e0e.htm (all the one-letter codes for the amino acids)  
  > **username_2**: @rajkarthikkumar that will do, I'll just make some sequences and their m/z values up  
  > **username_2**: @rajkarthikkumar I tried solution #2, unfortunately it is very hard to get a good error as my 'made up data' doesn't really have any correlations. So I'm going to try solution #1 somewhere soon, should work better  
  > **username_0**: I found a website with public spectra data. http://www.massbank.jp/QuickSearch.html If you search up, for example, Tyrosine, you get a list of example spectra http://www.massbank.jp/jsp/Dispatcher.jsp?type=disp&id=KO002701&site=0  
  > **username_0**: Do you mind if you send me your implementation of the LSTM? I'm struggling to see how to piece it together.  
  > **username_2**: Sorry! I started on it but it got out of my head. Ill send something tomorrow !  
  > **username_2**: @rajkarthikkumar updated the question  
  
  ---
  
  