0
$\begingroup$

I have $10000$ samples of 6-lettered strings of the following type
Left                  Right                  Classification
ATTGGC         GCGCTC            1
TAGCAA         ACGCTC             2
GGGGCG       TTTGCC             1
GCCTCG        GTTGCG            1
................
How can I use classification algorithms to classify the above text?

  1. I was thinking about generating tri-grams of each of the above strings in each row as [ATT,TTG,TGG,GGC,GCG,CGC,GCT,CTC] for the first row with classifier label 1. Now how should I proceed with the classification?
  2. Split each string into constituent characters and use that to classify, eg: for the first row, [A,T,T,G,G,C,G,C,G,C,T,C] for class label 1. I would then do one-hot encoding of the characters and use random forests etc to classify.
  3. Can anyone suggest me how to proceed with this problem?
$\endgroup$
  • $\begingroup$ So Left and Right are two variables? And you can't just input them into the model as is? $\endgroup$ – user2974951 Sep 12 '18 at 6:41
  • $\begingroup$ What model would you use in that case? $\endgroup$ – bandit_king28 Sep 12 '18 at 10:46
  • $\begingroup$ If the two variables have repeats of various combinations, then you can use a standard classification algorithm such as Random Forests. $\endgroup$ – user2974951 Sep 12 '18 at 10:54
  • $\begingroup$ Yes these are categorical variables in some sense. So the first left string "ATTGGC" might repeat again in the table somewhere. Can you please elaborate your answer? $\endgroup$ – bandit_king28 Sep 12 '18 at 13:56
  • $\begingroup$ If these are categorical variables then you can build a simple random forest classification model randomForest(class~Left+Right). Although if you are specifically interested in n-grams look at Gabizon's answer. $\endgroup$ – user2974951 Sep 12 '18 at 15:20
0
$\begingroup$

I would use e.g 1-gram, 2-gram and 3-gram (a total of 3 features). Also, if that's an issue you might want to indicate that a certain n-gram came from a Left or Right string, so encode that too. Finally a random forest combining all these features is an option.

$\endgroup$
  • $\begingroup$ Thanks for answering. I have a question in mind. So say I choose a 3-gram model. After one-hot encoding both the trigrams and the fact whether they came from left or right string, the number of features would increase dramatically (like 768 in my case). Do you have any suggestions on how to handle that? $\endgroup$ – bandit_king28 Sep 12 '18 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.