# Classification using n-grams [closed]

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?
• So Left and Right are two variables? And you can't just input them into the model as is? Sep 12 '18 at 6:41
• What model would you use in that case? Sep 12 '18 at 10:46
• If the two variables have repeats of various combinations, then you can use a standard classification algorithm such as Random Forests. Sep 12 '18 at 10:54
• 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? Sep 12 '18 at 13:56
• 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. Sep 12 '18 at 15:20